Trains the technique from
LeetCode 1041Robot Bounded In CircleThis 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 rover starts at the origin facing north and follows instructions, one character at a time: 'G' moves it one step forward in the direction it faces, 'L' turns it a quarter turn to the left, and 'R' a quarter turn to the right.
The rover repeats the whole list of instructions over and over, without end. Return true when there is some circle around the origin that the rover never leaves.
Example 1
A left turn and a right turn cancel each other out, so the rover ends four steps north still facing north, and every repeat carries it four further.
Example 2
The rover traces a unit square and comes back to where it started facing north, so it goes round that square forever.
Example 3
The rover ends two steps north and two east facing south. Repeating turns the whole journey a half turn each time, so the two halves cancel and it stays near home.
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 is_robot_bounded(instructions: str) -> bool:public boolean isRobotBounded(String instructions)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.