Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
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]
Run a DFS from the robot's position to make sure that you can reach the target, otherwise you should return -1.
Now that you are sure you can reach the target and that you know the grid, run Dijkstra to find the minimum cost.