A row of asteroids drifts along a straight line, listed in asteroids from left to right. The absolute value of each entry is the asteroid's size. The sign is its direction: positive moves right, negative moves left. They all move at the same speed.
Two asteroids collide only when the one on the left is moving right and the one on the right is moving left. When they hit, the smaller one is destroyed and the larger one carries on unchanged. If they are the same size, both are destroyed. Asteroids moving the same way never catch each other, and a left-mover sitting to the left of a right-mover is moving away from it.
Return the asteroids that are still there once no more collisions can happen, in their left-to-right order. If none survive, return an empty array.
-8 meets 2 first and destroys it, then meets 9, which is bigger. -4 heads left with nothing in its way, and 1 heads right behind everything.
-6 destroys 1, then meets 6. They are the same size, so both go and nothing is left.
Every left-mover is already to the left of every right-mover, so nothing ever meets.
Constraints
2 <= asteroids.length <= 10⁴-1000 <= asteroids[i] <= 1000asteroids[i] != 0A collision only happens when a right-mover has a left-mover directly to its right. Keep the asteroids that have survived so far; a new left-mover can only hit the right-movers at the end of that list.