Files
2020-08-07 17:06:53 +08:00

17 lines
834 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# [88. Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/description/)
## 题目
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. The number of elements initialized in nums1 and nums2 are m and n respectively.
## 题目大意
合并两个已经有序的数组,结果放在第一个数组中,第一个数组假设空间足够大。要求算法时间复杂度足够低。
## 解题思路
为了不大量移动元素就要从2个数组长度之和的最后一个位置开始依次选取两个数组中大的数从第一个数组的尾巴开始往头放只要循环一次以后就生成了合并以后的数组了。