Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Asteroid Collision

Medium Stack

Asteroids move along a line; the sign gives the direction (positive = right, negative = left) and the absolute value the size. When two meet, the smaller explodes (equal sizes both explode); same-direction asteroids never meet. Print the asteroids that remain.

Constraints

2 <= n <= 10^4 -1000 <= value <= 1000, value != 0

Discussion

No discussions yet.

Rewards · v2.1

Join Shalyam Newsletter

Get exclusive insights with every issue: education, research and innovation news.

One email a week. Unsubscribe any time.