Algorithm · Lyft · Medium
We are given two arrays representing a line of asteroids: one for their masses and one for their velocities. A velocity can be positive (moving to the right) or negative (moving to the left). We need to simulate all possible collisions until the system stabilizes and no more crashes can occur. Two asteroids will collide if either of these situations is true: The leading asteroid moves right (positive speed) and the following asteroid moves left (negative speed). Both move in…
Checking your access…