Robot Bounded In Circle
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A robot starts at (0, 0) on an infinite grid facing north. It follows a string instructions of these commands:
- 'G': move one unit forward in the current direction.
- 'L': turn 90 degrees left (counter-clockwise) in place.
- 'R': turn 90 degrees right (clockwise) in place.
The robot runs instructions in order and then repeats the whole string forever. Return true if there is some circle on the plane that the robot never leaves, and false if it drifts arbitrarily far away.
Examples
Constraints
- 1 <= instructions.length <= 100
- instructions[i] is 'G', 'L' or 'R'
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.