How to solve this??
Bfs can be used to solve it.
I didn’t solve this one yet, but it seems as simple shortest path problem, so simply use one of the well known algorithm f.e.:
This is a very known problem called as Rat in a Maze.
You can use BFS or Backtracking to solve this problem.
@betlista i think you do not need to use Dijkstra algorithm for this problem.
this function can solve the question recursive and easy
int minCost(int cost[C],int m, int n)
if (n < 0 || m < 0)
else if (m == 0 && n == 0)
return cost[m][n] + min( minCost(cost,m-1, n-1),
minCost(cost,m, n-1) );