The Robot Bounded In Circle interview question gives you a sequence of instructions (G = go forward, L = turn left, R = turn right) that a robot executes repeatedly on an infinite plane starting at the origin facing north. Determine whether the robot is bounded in a circle — meaning it will always return to the origin eventually — or will drift off to infinity.
This problem is asked at Apple, Goldman Sachs, Microsoft, Nvidia, Airbnb, Amazon, LinkedIn, Google, and Bloomberg because it requires mathematical reasoning about periodic motion and direction cycles. It tests whether candidates can derive a clean geometric invariant rather than simulating infinitely many steps. It appears in robotics, simulation, and path planning systems.
The pattern is mathematical simulation with cycle analysis. Simulate one cycle of instructions, tracking the robot's net displacement and final direction. After one cycle, the robot is bounded if either: (1) it is back at the origin (net displacement is zero), OR (2) it is not facing north (facing south, east, or west). In cases 2, executing at most 4 cycles will return it to the origin due to rotational symmetry.
Only simulate one pass — no need to simulate multiple cycles.
Instructions: "GLRG"
Start: position (0,0), facing North.
After one cycle: position (0,2), facing North. Not at origin and facing North → NOT bounded (will drift north forever). Return false.
Instructions: "GL"
true.(After 4 cycles it returns to origin.)
(direction + 1) % 4 for R and (direction - 1 + 4) % 4 for L.For the Robot Bounded In Circle coding problem, the math and simulation interview pattern requires understanding the geometric invariant. Memorize the key insight: simulate one cycle, check if position is (0,0) or direction is not North. Bloomberg and Airbnb interviewers often ask "why does non-north direction guarantee boundedness?" — be ready to explain the 4-cycle rotational symmetry argument clearly.