I'll trace [10, 2, -5]. Stack starts empty.
10 is positive. Push. Stack: [10]. 2 is positive. Push. Stack: [10, 2]. -5 is negative. Top is 2 (positive, smaller than ). Pop . Stack: [10]. Top is 10 (positive, larger than ). The asteroid is destroyed. Stack stays [10]. Result: [10].
Now try [-2, -1, 1, 2]. -2 is negative, stack empty, push. -1 is negative, top is negative, push. 1 is positive, push. 2 is positive, push. No collisions at all because the left-moving asteroids are to the left of the right-moving ones. Result: [-2, -1, 1, 2].
Each asteroid is pushed and popped at most once. That gives time. The stack holds at most elements, so space is .