< Previous Next >
[Depth-First Search] [Breadth-First Search] [Graph] [Interactive] [Heap (Priority Queue)]
Hint 1
The grid is at a maximum 100 x 100, so it is clever to assume that the robot's initial cell is grid[101][101] Hint 2
Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1. Hint 3
Now that you are sure you can reach the target and that you know the grid, run Dijkstra to find the minimum cost.