难度: easy

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.

思路:给定两个已经排序的array nums1 和nums2,将nums2 加入nums1中,成为一个有序的array。要求原位操作。
          双支针法,从nums1的最末数开始,谁大谁加入,然后再将指针前移一格。
          如果有一个array 的指针走到最前面以后,就跳出while循环,然后将剩余的加入nums1的前面。

leetcode 88[easy]---Merge Sorted Array
       


相关文章:

  • 2021-06-13
  • 2022-03-01
  • 2022-01-25
  • 2022-03-06
  • 2021-11-17
  • 2021-11-08
猜你喜欢
  • 2021-09-02
  • 2021-07-23
  • 2021-04-22
  • 2021-06-14
  • 2021-07-20
  • 2022-02-03
相关资源
相似解决方案