Skip to content

Latest commit

 

History

History
14 lines (12 loc) · 342 Bytes

2021-04-05.88.md

File metadata and controls

14 lines (12 loc) · 342 Bytes

88. 合并两个有序数组

https://leetcode-cn.com/problems/merge-sorted-array/

var merge = function(nums1, m, nums2, n) {
    let k = n + m - 1
    let i = m - 1, j = n  - 1
    while(i >= 0 && j >= 0) {
        nums1[k--] = nums1[i] >= nums2[j] ? nums1[i--] : nums2[j --]
    }
    while(j >= 0) nums1[k--] = nums2[j--]
};