Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.
Note: You can only move either down or right at any point in time.
Recurrence Relation: dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1])
The minimum cost to reach cell (i,j) is the value at that cell plus the minimum of the costs to reach the cell above or the cell to the left.
This is a natural extension of the Unique Paths problem, adding cost optimization.
grid = [[1,3,1],[1,5,1],[4,2,1]]7grid = [[1,2,3],[4,5,6]]12grid = [[1,2],[1,1]]3m == grid.lengthn == grid[i].length1 <= m, n <= 2000 <= grid[i][j] <= 200Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers