acash's blog

By acash, history, 7 years ago, In English

we have to find min cost path in a mtrix from top left to bottom right.

Move allowed -> Right,left,Bottom,Up.

I know suitable approach will be using Dijkstra But can we do this using Dp because here we can move in all 4 direction ,If yes then How?

Tags dp
  • Vote: I like it
  • -8
  • Vote: I do not like it

»
7 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

is cost value always non negative?

»
7 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

If you can move in all four directions, you have a graph with cycles and then you can't use dp.