Robot Return to Origin
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. The string moves lists its moves in order: 'U' up, 'D' down, 'L' left, 'R' right, each moving exactly one cell.
Return true if the robot is back at (0, 0) after executing every move, and false otherwise. The direction the robot faces is irrelevant; only its final position matters.
Examples
Constraints
- 1 <= moves.length <= 2 * 10^4
- `moves` contains only 'U', 'D', 'L', and 'R'.
- Each move shifts the robot by exactly one cell.
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.