Anyone know what Input: {1,2,2,2} Output: {1,2,#,#} Expected: {1,2,2,2}


  • 13
    J

    Does anyone know what

    Input: {1,2,2,2}
    Output: {1,2,#,#}
    Expected: {1,2,2,2}

    means?


  • 53

    The first half of the input is the label values of each node, while the second half of the input is the label values of each random node.

    Your output: {1,2,#,#} means that all of your random nodes are not pointing to anywhere (# = NULL).

    Maybe a picture is worth a thousand words. Below is a visualization of the input: {1,2,2,2}.

    0_1470150905890_2yxeznm.png


  • 0
    E
    This post is deleted!

  • 2
    S

    Yes, they should write this in the question.
    How else is the person supposed to understand.
    Thank you :)


  • 0
    H

    Input: {-1,-1}
    Output: {-1,#}
    Expected: {-1,-1}

    what does the -1 here mean then?


  • 0
    H
    This post is deleted!

  • 1

    For Input: {-1,-1}:

    For the first -1 value:

    It means the first node's label value is -1.

    For the second -1 value:

    The first node's random points to the node with label -1, which is itself.


  • 0

    Can this be true? node1.random = node2 and there's no "next" relationships. Thanks!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.