Approach hintTry it first, then revealHide
Keep the surviving asteroids on a stack. Only a left-moving asteroid can hit a right-moving one on top of the stack; resolve such collisions in a loop, remembering that equal sizes destroy both.
Keep the surviving asteroids on a stack. Only a left-moving asteroid can hit a right-moving one on top of the stack; resolve such collisions in a loop, remembering that equal sizes destroy both.