110.Minimum Path Sum
1.Description(Easy)
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.
Notice
You can only move either down or right at any point in time.
2.Code
坐标型动态规划
• state: f[x][y]从起点走到x,y的最短路径
• function: f[x][y] = min(f[x-1][y], f[x][y-1]) + A[x][y]
• intialize: f[i][0] = sum(0,0 ~ i,0)
• f[0][i] = sum(0,0 ~ 0,i)
• answer: f[n-1][m-1]
Last updated