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

Commit2ec37ef

Browse files
authored
Merge pull requestneetcode-gh#2509 from Dhyan-P-Shetty/main
Create: 0735-asteroid-collision.py
2 parents61efc9a +ca450ea commit2ec37ef

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎python/0735-asteroid-collision.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
classSolution:
2+
defasteroidCollision(self,asteroids:List[int])->List[int]:
3+
stack= []
4+
5+
forainasteroids:
6+
whilestackanda<0andstack[-1]>0:
7+
diff=a+stack[-1]
8+
ifdiff>0:
9+
a=0
10+
elifdiff<0:
11+
stack.pop()
12+
else:
13+
a=0
14+
stack.pop()
15+
ifa:
16+
stack.append(a)
17+
18+
returnstack

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp