Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2e3bb0a

Browse files
Create 088.py
1 parent 48af27b commit 2e3bb0a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎001-500/088.py‎

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /