Is this a valid testcase?


  • 2
    D

    I'm seeing this:

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

    Why would the initial argument ([0]) have a length of 0? It's not an empty list.


  • 4
    C

    Zero is the size of the first numbers to sort, the size of the first array is in fact N+M, which 0+1 = 1, which is valid.


  • 0
    D

    I still don't understand. If the input for num1 is [0], that's an array of length 1. So m should equal 1. It seems to me it should be:

    input
    [0]
    1
    [1]
    1
    with an expected output of [0,1]

    Hope you can clarify for me.


  • 0
    Y

    I think [0] is place holder.
    For example:
    num1 = [ 0,0,0,0,0], m = 0; num2 = [1,2,3,4,5], size = 5;

    Although m = 0, num1 's size should still be m+n = 5 because it will hold the merged array. So num1 should have 5 elements, and all the initial values should be 0.


  • 0
    D

    Ah, that makes sense. Thanks!


Log in to reply
 

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