Which one is correct?


  • 0
    D
    void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) 
    {
    while(n > 0) nums1[m + n]     = (m == 0||nums1[ m- 1] < nums2[n - 1]) ? nums2[--n]:nums1[--m];
    
    //while(n > 0) nums1[m + n - 1] = (m == 0||nums1[m - 1] < nums2[n - 1]) ? nums2[--n]:nums1[--m];
    }
    

    The first one works fine on VS 2010, but gets runtime error here. The second is accepted but couldn't run through on VS. Which one is correct? Thanks.


Log in to reply
 

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