https://leetcode.com/problems/asteroid-collision/

給一個陣列,代表小行星體積與運行方向

正負號代表方向

絕對值代表體積

當兩個小行星方向相反,就會相撞,留下大的

回傳穩定後的結果

Example 1:

Input: asteroids = [5,10,-5]
Output: [5,10]
Explanation: The 10 and -5 collide resulting in 10. The 5 and 10 never collide.

Example 2:

Input: asteroids = [8,-8]
Output: []
Explanation: The 8 and -8 collide exploding each other.

Example 3:

Input: asteroids = [10,2,-5]
Output: [10]
Explanation: The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.

<aside> 💡 想清楚要遞迴處理的東西

</aside>

走訪星球陣列

每顆星球先判斷是否該與前一顆相撞,以及相撞後的結果

計算完之後,推入stack