0 left to right, each at its own point. The string moves describes them: moves[i] is 'L' (the car drives left), 'R' (drives right) or 'S' (stays put). All moving cars travel at the same speed.
Crashes are scored like this:
- two cars driving toward each other collide, adding 2;
- a moving car hits a standing one, adding 1.
After a crash, the cars involved stop where they collided and stay there. Nobody else ever changes direction.
Return the total crash score.moves="RSLR" → 2
Car 0 runs into the parked car 1 (+1), and car 2 hits it from the other side (+1). Car 3 drives off to the right. Total 2.
moves="RRL" → 3
Cars 1 and 2 meet head-on (+2) and stop, then car 0 runs into them (+1). Total 3.
moves="LSR" → 0
moves is 'L', 'R' or 'S'moves="RSLR"
2
Run checks the first 3 tests in your browser. Submit checks all 180 tests on the server, hidden ones included.