Space rocks drift along a straight line. All of them have the same speed. The list asteroids shows them from left to right.
The size of a rock is the absolute value of its number. The sign gives its direction. A positive number moves to the right. A negative number moves to the left.
When two rocks meet head-on, the smaller rock is destroyed. If both have the same size, both are destroyed. Two rocks that move in the same direction never meet.
Return the rocks that are left when no more meetings can happen. Keep them in their original order.
Examples
Example 1:
Input: asteroids = [6,4,-4,2]
Output: [6,2]
Explanation: 4 and -4 meet. They have the same size, so both are destroyed. The rocks 6 and 2 both move right, so they stay.
Example 2:
Input: asteroids = [-4,-6,3]
Output: [-4,-6,3]
Explanation: The rocks -4 and -6 move left, away from the rock 3 that moves right. Nothing meets, so nobody is destroyed.
Example 3:
Input: asteroids = [3,6,-6,9,-2,-12]
Output: [-12]
Explanation: 6 and -6 destroy each other. Then 9 meets -2, and -2 is destroyed. Then 9 meets -12, and 9 is destroyed. Then 3 meets -12, and 3 is destroyed. Only -12 is left.