Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Process the robots in the order of their positions to ensure that we process the collisions correctly.
To optimize the solution, use a stack to keep track of the surviving robots as we iterate through the positions.
Instead of simulating each collision, check the current robot against the top of the stack (if it exists) to determine if a collision occurs.