← 返回 meta 的题目列表在原地合并两个有序数组
类型:online_judge
Given two sorted integer arrays nums1 and nums2, with nums1 having a length of m+n where the first m elements contain the data to be merged and the remaining n elements are empty representing the necessary additional space. Merge nums2 into nums1 in-place so that the result is ordered.
Example:
Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
Output: [1,2,2,3,5,6]
Constraints:
-10^9 <= nums1[i], nums2[i] <= 10^9
nums1.length == m + n
nums2.length == n
Example
Input
3
1 2 3 0 0 0
3
2 5 6