88. Merge Sorted Array
Practice Merge Sorted Array for free on NudgeCode: Easy, Two Pointers pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
nums1 and nums2 are sorted in non-decreasing order. The first m slots of nums1 hold its values and the last n slots are 0 placeholders; nums2 holds n values.
Merge nums2 into nums1 in place so that nums1 becomes one sorted array of length m + n. Don't return anything.
Example
nums1 = [1,4,7,0,0,0], m = 3, nums2 = [2,5,6], n = 3 -> [1,2,4,5,6,7]
Constraints
- nums1.length == m + n
- 0 <= m, n <= 200, 1 <= m + n <= 200
- -10^9 <= nums1[i], nums2[j] <= 10^9