@@ -0,0 +1,27 @@
+from typing import List
+
+def merge(nums1: List[int], m: int, nums2: List[int], n: int) -> None:
+ # 法1
+ nums1[m:] = nums2
+ nums1.sort()
+ #双指针
+ Sort = []
+ p1, p2 = 0, 0
+ while p1 < m or p2 < n:
+ if p1 == m:
+ Sort.append(nums2[p2])
+ p2 += 1
+ elif p2 == n:
+ Sort.append(nums1[p1])
+ p1 += 1
+ elif nums1[p1] <= nums2[p2]:
+ else:
+ nums1[:] = Sort
+print(merge(nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3))
@@ -0,0 +1 @@
+有排序:用双指针