Code RoomRobot bounded in circle
MediumPrep Room Coding #774

Robot bounded in circle

CodingAlgorithms & data structuresMid–Senior~25 min

A robot starts at the origin (0,0) facing north on an infinite plane. Given a string of instructions where 'G' moves it one step forward, 'L' turns it 90 degrees left, and 'R' turns it 90 degrees right, the robot executes the whole instruction string repeatedly forever. Return True if and only if there exists a circle such that the robot never leaves it (its trajectory is bounded). The instruction string is non-empty.

Implement
robot_bounded(instructions: str) → bool
Examples
in["GGLLGG"]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 25 min
InputExpectedGot
["GGLLGG"]truenot run yetsample