Approach Summary
Push positive asteroids onto the stack. For negative ones, pop and compare until stack is empty or top is negative. Simulate collisions.
How to Recognize This Pattern
- Collisions between opposing elements — last-in-first-out resolution
- Stack models "pending" asteroids
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(n)
Tags
Array Stack Simulation