Movatterモバイル変換


[0]ホーム

URL:


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

Commitdc797ef

Browse files
Update 088.py
1 parent2e3bb0a commitdc797ef

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎001-500/088.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,30 @@ def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
1818
k-=1
1919

2020

21+
22+
classSolution(object):
23+
defmerge(self,nums1,m,nums2,n):
24+
"""
25+
:type nums1: List[int]
26+
:type m: int
27+
:type nums2: List[int]
28+
:type n: int
29+
:rtype: None Do not return anything, modify nums1 in-place instead.
30+
"""
31+
i=m+n-1
32+
j=n-1
33+
k=m-1
34+
35+
whilej>=0andk>=0:
36+
ifnums2[j]>nums1[k]:
37+
nums1[i]=nums2[j]
38+
j-=1
39+
else:
40+
nums1[i]=nums1[k]
41+
k-=1
42+
i-=1
43+
44+
whilei>=0andj>=0:
45+
nums1[i]=nums2[j]
46+
j-=1
47+
i-=1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp