Why my code can't pass the case [0] 0 [1] 1?


  • 0
    C

    void merge(int* nums1, int m, int* nums2, int n) {

    if(m==0)
    {
        nums1=nums2;
        return;
    }
    else if(n==0)return;
    int it1=m-1;
    int it2=n-1;
    int k=m+n-1;
    while(it1>=0&&it2>=0)
    {
        if(nums1[it1]>=nums2[it2])
        {
            nums1[k--]=nums1[it1--];
        }
        else
        {
            nums1[k--]=nums2[it2--];
        }
    }
    

    }


  • 0
    N
    This post is deleted!

Log in to reply
 

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