Given asteroids in a row, each value's sign is its direction (positive = right, negative = left) and its magnitude is size. Asteroids moving toward each other collide; the smaller explodes, and equal sizes both explode. Same-direction asteroids never meet. Return the state after all collisions. The input is JSON {asteroids}.
Input: JSON {asteroids}.
Output: Array — the surviving asteroids.
Input: {"asteroids":[5,10,-5]}
Output: [5,10]
Explanation: 10 destroys -5.Input: {"asteroids":[8,-8]}
Output: []
Explanation: Equal sizes both explode.Input: {"asteroids":[10,2,-5]}
Output: [10]
Explanation: -5 destroys 2 then loses to 10.1<=n<=10^4values nonzero