The Robot Room Cleaner interview question is an interactive problem where you control a robot in a room represented as a grid. You can call API methods: move() (move forward), turnLeft(), turnRight(), and clean(). The robot starts at an unknown position and cannot see the grid directly. You must write an algorithm that ensures every reachable cell is cleaned using only these four API calls.
This HARD problem is asked at Uber, Citadel, Microsoft, Meta, Two Sigma, DRW, Amazon, LinkedIn, TikTok, and Google because it tests advanced backtracking with state tracking under API constraints. It is an "interactive" problem where you cannot read the grid directly — you must infer your position from the robot's movements. This models real robotic navigation: Roomba-style vacuum cleaners, warehouse robots, and autonomous vehicles that must explore unknown spaces.
The pattern is backtracking with direction state and visited set. Maintain a set of visited cells (represented as relative coordinates from the start). Maintain the robot's current direction (0=up, 1=right, 2=down, 3=left). Use DFS: at each cell, try all 4 directions. For each direction: if the neighbor is not visited and move() succeeds, recurse into the neighbor, then return to the current cell (turn 180°, move, turn 180° — this is the "go back" step). Track direction as a state variable, updating it when turning.
Start at (0,0) facing up. Try all 4 directions:
The key is the "go back" sequence: turnRight(), turnRight(), move(), turnRight(), turnRight() — rotate 180°, move back, rotate 180° to face original direction.
For the Robot Room Cleaner coding problem, the backtracking interview pattern with interactive API usage is the core. The "go back" maneuver (two right turns, move, two right turns) is the most critical piece — practice it separately. Google and Two Sigma interviewers test whether you handle all four directions symmetrically using a direction array [(−1,0),(0,1),(1,0),(0,−1)]. State the go-back logic explicitly before coding to show you understand the movement model.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| N-Queens II | Hard | Solve | |
| Tiling a Rectangle with the Fewest Squares | Hard | Solve | |
| Combinations | Medium | Solve | |
| Factor Combinations | Medium | Solve | |
| N-Queens | Hard | Solve |