735. Asteroid Collision
class Solution:
def asteroidCollision(self, asteroids: List[int]) -> List[int]:
res = []
for a in asteroids:
while res and res[-1] > 0 and a < 0:
if res[-1] + a < 0:
res.pop()
elif res[-1] + a > 0:
break
else:
res.pop()
break
else:
res.append(a)
return res