LeetCode: Merge two sorted arrays

Table of contents

topic

example

train of thought

the code

appendix


topic

You are given two arrays of integers nums1 and nums2 in non-decreasing order, and two integers m and n denoting the number of elements in nums1 and nums2 respectively.

Please merge nums2 into nums1 so that the merged array is also arranged in non-decreasing order.

Note: Ultimately, the merged array should not be returned by the function, but stored in the array nums1. To cope with this situation, the initial length of nums1 is m + n, where the first m elements represent elements that should be merged, and the last n elements are 0 and should be ignored. nums2 has length n.

example

Example 1:

Enter ࿱

Guess you like

Origin blog.csdn.net/qq_34417408/article/details/124951625