###### LeetCode 64 Minimum Path Sum (数字三角形)

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 class Solution {
public int minPathSum(int[][] grid) {
int n = grid.length;
int m = grid[0].length;
int[][] dp = new int[n][m];
for(int i = 0; i < n; i ++) {
Arrays.fill(dp[i], 0);
}
dp[0][0] = grid[0][0];
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) {
if(i > 0 && j > 0) {
dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - 1]) + grid[i][j];
}
else if(i > 0) {
dp[i][j] = dp[i - 1][j] + grid[i][j];
}
else if(j > 0) {
dp[i][j] = dp[i][j - 1] + grid[i][j];
}
}
}
return dp[n - 1][m - 1];
}
}

#### LeetCode 64 — Minimum Path Sum（C++ Java Python）

2014-02-26 22:09:52

#### [LeetCode]64.Minimum Path Sum

2015-02-04 15:55:25

#### leetCode 64.Minimum Path Sum (最短路) 解题思路和方法

2015-07-17 16:25:43

#### leetcode 64. Minimum Path Sum-最小路径和|动态规划

2016-05-31 20:11:51

#### LeetCode || Minimum Path Sum

2014-10-19 11:40:15

#### LeetCode 64. Minimum Path Sum 解题报告

2016-02-20 18:23:43

#### Minimum Path Sum -- LeetCode

2014-03-27 07:04:39

#### 【LeetCode-面试算法经典-Java实现】【064-Minimum Path Sum（最小路径和）】

2015-08-02 06:05:34

#### leetcode64-Minimum Path Sum(最小路径和)

2016-02-17 12:08:44

#### LeetCode -- Triangle 路径求最小和（ 动态规划问题）

2014-05-25 18:10:15

## 不良信息举报

LeetCode 64 Minimum Path Sum (数字三角形)