nums1 contains m sorted values followed by enough zero placeholders to hold nums2. nums2 contains n sorted values.
Merge nums2 into nums1 in non-decreasing order and return nums1.
Inputnums1 = [1, 2, 3, 0, 0, 0], m = 3, nums2 = [2, 5, 6], n = 3
Output[1, 2, 2, 3, 5, 6]
The last three zeros in nums1 reserve space for nums2. Merging [1, 2, 3] and [2, 5, 6] in order gives [1, 2, 2, 3, 5, 6].
Inputnums1 = [1], m = 1, nums2 = [], n = 0
Output[1]
nums2 is empty, so the merged array contains only the original 1.
nums1.length = m + n