Minimum cost to reach destination – Dynamic Programming

Give n*n matrix find minimum cost required to reach from source to destination.

Lets consider source is Array [0][0] and destination is Array [n-1][ n-1] the each elements also represent as cost

You can only move down, right and diagonally lower elements from a given element.

For example:

[1, 2, 3]
[4, 5, 6]
[8, 2, 1]

The path of minimum cost is 1 ->5->1 so minimum cost to reach destination is 7.

Dynamic Programming Approach:

Leave a Reply

Your email address will not be published. Required fields are marked *