class Solution:
def asteroidCollision(self, asteroids: List[int]) -> List[int]:
stack=deque()
for a in asteroids:
add=True
while stack and stack[-1]>0 and a<0:
if abs(stack[-1])>abs(a):
add=False
break
elif abs(stack[-1])==abs(a):
stack.pop()
add=False
break
else:
stack.pop()
add=True
if add:
stack.append(a)
return list(stack)
03-06
218
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-31
449
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-29
354
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-03
660
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-02
916
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)