moves, a string of the characters L, R and _. Every character is a step of length 1:
- L always goes left;
- R always goes right;
- _ goes whichever way you choose.
Return the greatest distance from point 0 the robot can end up at once the whole program has run.moves='R__L_R' → 4
Turning all three free steps to the right gives R R R L R R, which ends at point 4.
moves='LLR_' → 2
The fixed steps end at -1; taking the free step left reaches -2.
moves='LR' → 0
moves contains only the characters L, R and _moves='R__L_R'
4
Run checks the first 3 tests in your browser. Submit checks all 152 tests on the server, hidden ones included.