diff --git a/content/leetcode/2024/1.md b/content/leetcode/2024/1.md index 3f5df5ac..b653e48b 100644 --- a/content/leetcode/2024/1.md +++ b/content/leetcode/2024/1.md @@ -3,6 +3,36 @@ title: 2024.1 draft: false --- +# 2024.1.22 + +```python +# +# @lc app=leetcode.cn id=735 lang=python3 +# +# [735] 小行星碰撞 +# + + +# @lc code=start +class Solution: + def asteroidCollision(self, asteroids: List[int]) -> List[int]: + stack = [] + for a in asteroids: + while stack and a < 0 < stack[-1]: + if stack[-1] < -a: + stack.pop() + continue + elif stack[-1] == -a: + stack.pop() + break + else: + stack.append(a) + return stack + + +# @lc code=end +``` + # 2024.1.21 ```python