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

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.