Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 443 Bytes

88.merge-sorted-array.md

File metadata and controls

20 lines (17 loc) · 443 Bytes

合并两个有序数组

题目

思路

直接合并并排序就完事了

/**
 * @param {number[]} nums1
 * @param {number} m
 * @param {number[]} nums2
 * @param {number} n
 * @return {void} Do not return anything, modify nums1 in-place instead.
 */
var merge = function(nums1, m, nums2, n) {
  nums1.splice(m, n, ...nums2.splice(0, n))
  nums1.sort((x, y) => x - y)
};