LC 64 Minimum Path Sum(M)
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.
public int minPathSum(int[][] grid)
边界条件 保证数组有行列
解题思路 DP
因为不能左或上, 所以 grid[r][c] = min(grid[r-1][c], grip[r][c-1]) + grid[r][c]
Last updated
Was this helpful?