What is the Submission result really Output out?


  • 0
    W

    Using Python.
    Noticed something wrong with the testing process.
    If you just type in

    if m == 0:
                nums1 = nums2
                print nums1
    

    Then the result would be

    Input:
    [0]
    0
    [1]
    1
    Output:
    [0]
    Expected:
    [1]
    Stdout:
    [1]
    

    That's strange.... When I print out it says [1] and it still says [0] in Output.
    And something even more strange..
    If I just type in

    if m == 0:
            nums1[:n] = nums2[:n]
            print nums1
    

    I'm getting

    Input:
    [0]
    0
    [1]
    1
    Output:
    [1,1]
    Expected:
    [1]
    Stdout:
    [1]
    

    So what is really going on behind the checking function? What is the Output really looking at?


  • 1
    F

    Because the reference of nums1 is a temporary parameter, but not the real one.
    So it's ineffective to edit the reference.Try to edit the values in nums1, :)


Log in to reply
 

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