88. Merge Sorted Array
Intitution
We are given two sorted arrays and need to merge them into nums1
in-place. Since nums1
has enough space at the end, we can start filling from the back to avoid overwriting existing values in nums1
.
We merge from the back (from the largest index) — placing the largest elements first — so we always have space to write into.
Complexity
Space Complexity
Time Complexity
Code
Last updated