O30
Asteroid Collision
Problem Statement & Objective
We are given an array asteroids of integers representing asteroids in a row. Find out the state of the asteroids after all collisions.
Function Signature (Python)
asteroid_collision(asteroids: list[int]) -> list[int]Input & Output Contract
Output Rule:Kalan asteroidlerin tam sayı listesi.
System Constraints
2 <= asteroidler.length <= 10^4
-1000 <= asteroidler[i] <= 1000
asteroidler[i] != 0Example Execution Walkthrough
asteroidler = [5, 10, -5] -> 10 ve -5 çarpışır, 10 kazanır -> [5, 10]
asteroidler = [8, -8] -> ikisi de patlar -> []Example Test Scenarios (3)
Example 1
Input:
[[5,10,-5]]Expected Output:
[5,10]Example 2: Eşit Boyut
Input:
[[8,-8]]Expected Output:
[]Example 3: Zincirleme
Input:
[[10,2,-5]]Expected Output:
[10]