Trains the technique from
LeetCode 657Robot Return to OriginThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A floor shuttle in a parts warehouse begins parked on its charging dock and then plays back a tape of single-letter steps, moves, one step per letter, each step covering one tile:
'U' moves it one tile up the aisle,'D' moves it one tile down the aisle,'L' moves it one tile to the left,'R' moves it one tile to the right.The floor is unobstructed, so every step is carried out exactly as written and the shuttle may pass over the dock tile as often as it likes mid-tape.
Return true when the shuttle is sitting on the dock tile once the whole tape has been played back, and false when it stops anywhere else.
Example 1
Two steps right then two steps left leave the shuttle on the dock tile, so the answer is true.
Example 2
The shuttle finishes one tile to the right of the dock and one tile up the aisle from it, so it is not parked.
Example 3
The shuttle walks a small loop, passing three other tiles, and its last step puts it back on the dock.
Example 4
A single step down the aisle leaves the shuttle one tile away from the dock.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def ends_on_dock(tape: str) -> bool:public boolean endsOnDock(String tape)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.