Merge Sorted Array
- javascript
- array
- sorting
- two pointers
Problem URL:Merge Sorted Array
My Solution
JavaScript
/**
* @param {number[]} nums1
* @param {number} m
* @param {number[]} nums2
* @param {number} n
* @return {void} Do not return anything, modify nums1 in-place instead.
*/
const merge = (nums1, m, nums2, n) => {
nums1.splice(m, nums1.length - m, ...nums2);
nums1.sort((a, b) => a - b);
};
Let's Connect
Twitter •GitHub •LinkedIn