This was the difficult question I remember they asked. It's a variant of this question.
Leetcode 489. Robot Room Cleaner
Control a robot with only move/turn/clean APIs to traverse and clean every reachable cell in an unknown grid with obstacles and no global map. The challenge is to explore the entire accessible area using DFS/backtracking while tracking visited coordinates and managing orientation to avoid revisiting or getting stuck.
DESCRIPTION
Control a robot with only move/turn/clean APIs to traverse and clean every reachable cell in an unknown grid with obstacles and no global map. The challenge is to explore the entire accessible area using DFS/backtracking while tracking visited coordinates and managing orientation to avoid revisiting or getting stuck.
Input:
room = [
[1,1,1,1,1,0,1,1],
[1,1,1,1,1,0,1,1],
[1,0,1,1,1,1,1,1],
[0,0,0,1,0,0,0,0],
[1,1,1,1,1,1,1,1]
],
row = 1,
col = 3
Output:
Robot cleans all reachable cells
Explanation: The robot starts at position (1,3) and explores the entire reachable area using DFS with backtracking. Cells with 0 are obstacles, cells with 1 are cleanable.
Constraints:
1 <= room.length <= 100
1 <= room[i].length <= 200
room[i][j] is either 0 (obstacle) or 1 (cleanable)
The robot starts in a cleanable cell
All cleanable cells are connected (reachable from the starting position)
Robot APIs: move() returns boolean, turnLeft() and clean() return void