Asteroid Collision

Medium Stack & Queue AI round

How it works

  1. Press Start. 30:00 on the clock, and it keeps running if you leave the page.
  2. Use an AI agent. 20 messages, anything about the problem. It can write code, but how you use it is scored.
  3. Run your code on the examples and your own cases, up to 20 runs in 10 minutes.
  4. Submit to run the hidden tests and end the round.

What the report looks at Example figures

  • SolutionOptimal · O(n)
  • Hidden tests12 of 12
  • AI agent use78 / 100
  • Cost$0.004
  • Time14:32 of 30:00

The problem

asteroids is a row of asteroids, read from left to right. A positive number is an asteroid flying right and a negative one an asteroid flying left; the number without its sign is the asteroid's size. They all fly at one speed.

An asteroid flying right crashes into the asteroids flying left that reach it from its right. In a crash the smaller asteroid is destroyed, and two of one size are both destroyed; the winner flies on and may crash again. Asteroids flying the same way, or away from each other, never crash.

Return the asteroids still flying once no more crashes can happen, in their order from left to right.

Read the full problem

Solve it without the AI agent

Write it in Python, Java or C++, run it on your own cases, and submit against hidden tests.

Open the practice page

More Stack & Queue

All Stack & Queue problems