We are given an array `asteroids` of integers representing asteroids in a row.
For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.
Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.
### Constraints
- `2 <= asteroids.length <= 10^4`
- `-1000 <= asteroids[i] <= 1000`
- `asteroids[i] != 0`
### Input Format
A single line containing space-separated integers for `asteroids`.
### Output Format
Print space-separated integers representing surviving asteroids, or empty line if none survive.
Sample Cases
Example 1Sample Case
Input: 5 10 -5
Output: 5 10
Example 2Sample Case
Input: 8 -8
Output:
Example 3Sample Case
Input: 5
Output: 5
Example 4Sample Case
Input: 5 5
Output: 5 5
Constraints
Runtime Limit: 2000 ms per test batch
Memory Limit: 256 MB
Standard I/O stream reading
Official submissions are evaluated against hidden test cases on the server to verify time & memory complexity.