Algorithm · Amazon · Medium
Asteroid Collision Medium · Topics · Company Tags · Hints You are given an array rocks of non‑zero integers, each representing a rock moving along a straight line. The absolute value is the rock’s mass, while the sign encodes its direction: positive → right, negative → left. All rocks travel at the same speed. When a right‑moving rock is immediately followed (in the array order) by a left‑moving rock, the two will eventually meet and collide. The outcome of a collision is…
Checking your access…