< Previous
Next >
[Heap]
[Depth-first Search]
[Graph]
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.