Minimum path sum in matrix

Question

Given a matrix M, write a function to find the minimum sum of all numbers encountered on the path moving from the top left to the bottom right of the matrix. You are only allowed to move down or to the right at each step, and your matrix will be filled with non-negative numbers.

For example:

M = [[1, 2, 3], 
[4, 1, 2], 
[1, 5, 3]]
# Returns 9 because we go from 1 -> 2 -> 1 -> 2 -> 3 = 9

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now