Solve the Asteroid Collision problem.
Asked in the Coding and DevOps/SRE stage. Interviewed in Python; logic was explained first, followed by live coding on the shared terminal.
Given an integer array asteroids, positive values move right and negative values move left. Every asteroid moves at the same speed. Return the array after all possible collisions, preserving the original order of surviving asteroids. A collision occurs only when a right-moving asteroid is immediately followed by a left-moving asteroid. The smaller asteroid is destroyed; equal sizes destroy both.
def asteroid_collision(asteroids):