Merge Sorted Array
Easy · Arrays & Strings · about 10 minutes
Asked at Meta, Google, Bloomberg, Amazon, Microsoft, Two Sigma.
You are given two sorted integer arrays nums1 and nums2, and integers m and n. nums1 has length m + n: its first m values are the real elements and the last n are zeros reserved as space. Merge nums2 into nums1 in place so nums1 is sorted, and return it.