← 返回 meta 的题目列表Merge Two Sorted Arrays In-Place
类型:online_judge
meta
Given two sorted integer arrays nums1 and nums2, and their element counts m and n, merge nums2 into nums1 so that nums1 becomes a sorted array. The final nums1 should have a length of m + n.
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:
nums1.length == m + n
nums2.length == n
0 <= m, n <= 200
1 <= m + n <= 200
-10^9 <= nums1[i], nums2[i] <= 10^9
Example
Input
[1,2,3,0,0,0] 3 [2,5,6] 3