# 120. Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.

For example, given the following triangle

[
[2],
[3,4],
[6,5,7],
[4,1,8,3]
]


The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).

class Solution {
public:
int minimumTotal(vector<vector<int>>& triangle) {
vector<int> temp;
int lineLen = triangle.size();
if(lineLen == 0) return 0;
for(int j = 0; j < lineLen; j++){
temp.push_back(triangle[lineLen-1][j]);
}
for(int i = lineLen - 2; i >= 0; i--){
for(int j = 0; j <= i; j++){
temp[j] = min(temp[j], temp[j+1]) + triangle[i][j];
}
}
return temp[0];
}
};

#### 【LeetCode】120. Triangle 基于C++和Java的分析及解法，动态规划

2016-05-15 21:05:31

#### Triangle 递归解法

2016-01-23 10:44:57

#### 【LeetCode-面试算法经典-Java实现】【120-Triangle（三角形）】

2015-08-14 06:13:18

#### LeetCode 120. Triangle 解题报告

2016-02-19 18:24:22

#### LeetCode120——Triangle

2015-08-13 20:32:26

#### 【LEETCODE】120- Triangle [Python]

2016-08-17 00:01:15

#### LeetCode(120)Triangle

2014-02-27 23:50:35

#### leetcode题解-120. Triangle

2017-04-17 11:56:56

#### Leetcode 120 Triangle 三角形最小路径和

2015-07-03 14:29:16

#### leetcode-120-Triangle 动态规划

2016-11-03 20:29:23