2 Line Java solution


  • 0
    G
     int currentPtr = m-- + n-- -1; //start from highest valid index and fill by selecting largest of two arrays from it's end
     while(currentPtr > -1 && n > -1)  nums1[currentPtr--] = (m > -1 && nums1[m] > nums2[n]) ? nums1[m--] : nums2[n--];
            
    

Log in to reply
 

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