You get two integer arrays, nums1 and nums2, each already sorted from smallest to largest. Only the first m slots of nums1 hold real values. After them, nums1 has n more slots set to 0: spare room, exactly enough to fit all n values of nums2.
Merge nums2 into nums1 so that nums1 ends up holding all m + n values in sorted order (smallest first, duplicates kept). Change nums1 itself and return nothing: the answer is what nums1 holds once your function finishes.
The real values are 2, 4, 7 and 3, 9. Merged in order, they fill all five slots of nums1.
-1 is smaller than everything already in nums1, so both of its values move one slot right to make room at the front.
With m = 0, nums1 holds no real values yet: its two zeros are only room, and nums2 fills them.
Constraints
nums1.length == m + n and nums2.length == n0 <= m, n <= 200 and 1 <= m + n <= 200-10⁹ <= nums1[i], nums2[j] <= 10⁹m values of nums1, and all of nums2, are sorted from smallest to largest.n slots of nums1 are 0.Merging from the front would overwrite values of nums1 you haven't placed yet. Where in nums1 is there free space that nothing still needs?