Skip to content

Commit f8b782d

Browse files
Add files via upload
1 parent 8ba1cde commit f8b782d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 36ms 99.86%
2+
class Solution:
3+
def merge(self, nums1, m, nums2, n):
4+
"""
5+
:type nums1: List[int]
6+
:type m: int
7+
:type nums2: List[int]
8+
:type n: int
9+
:rtype: void Do not return anything, modify nums1 in-place instead.
10+
"""
11+
while m >= 1 and n >= 1:
12+
if nums1[m - 1] > nums2[n - 1]:
13+
nums1[m + n - 1] = nums1[m - 1]
14+
m -= 1
15+
else:
16+
nums1[m + n - 1] = nums2[n - 1]
17+
n -= 1
18+
nums1[:n] = nums2[:n]

0 commit comments

Comments
 (0)