3 lines java code


  • 0

    '''
    public void merge(int[] nums1, int m, int[] nums2, int n) {
    int mPointer = m-1, nPointer = n-1, count = 0;
    while (mPointer > -1 && nPointer > -1) {
    nums1[m + n - ++count] = nums1[mPointer] > nums2[nPointer] ? nums1[mPointer--] : nums2[nPointer--];
    }
    while(nPointer > -1) nums1[nPointer] = nums2[nPointer--];
    }
    '''


Log in to reply
 

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