Free written solution

Robot Collisions (LeetCode 2751): Solution and Explanation

Robots on a line move left or right at the same speed. When two meet, the weaker one is removed and the stronger loses one health, or both go on a tie. Return the survivors' healths in input order. For Example 2 the answer is [14].

Read the intuition, approach, code and complexity →