Short Javascript Solution


  • 2
    T
    var merge = function (nums1, m, nums2, n) {
        var len = m + n;
        m--;
        n--;
        while (len--) {
            if (n < 0 || nums1[m] > nums2[n]) {
                nums1[len] = nums1[m--];
            } else {
                nums1[len] = nums2[n--];
            }
        }
    };

Log in to reply
 

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