← 返回 linkedin 的题目列表Robot Room Cleaner
类型:online_judge
Suppose there is a robot located in a room. The room is represented as an m x n grid, where 0 indicates an empty square and 1 indicates an obstacle. The robot is restricted to moving on empty squares only. The robot can move forward, backward, turn left, and turn right and can sense if there is an obstacle one square ahead. Design an algorithm and implement a method that enables the robot to clean all reachable empty squares. You can only call the following methods: move(), turnLeft(), and turnRight().
Example
Input
m=5,n=5,grid=[[0,0,0,0,0],[0,1,1,0,0],[0,0,0,1,0],[0,0,0,0,0],[1,0,1,0,0]]