Asteroid collision

Write codeMedium25 minBloomberg style

Your task

Given an array of integers representing asteroids in a row, the absolute value is each asteroid's size and the sign is its direction (positive = moving right, negative = moving left). All asteroids move at the same speed. When two asteroids collide, the smaller one explodes; if both are equal, both explode. Two asteroids moving in the same direction, or a left-mover to the left of a right-mover, never meet. Return the state of the asteroids after all collisions resolve.

Examples

asteroid_collision(asteroids: list[int]) -> list[int]
Example 1
Inputasteroid_collision([5, 10, -5])
Output[5, 10]