# [leetcode]120. Triangle

class Solution {
public:
int minimumTotal(vector<vector<int>>& triangle)
{
int n=triangle.size();

for(int i=1;i<n;i++)
{
triangle[i][0]+=triangle[i-1][0];
for(int j=1;j<i;j++)
triangle[i][j]=triangle[i][j]+min(triangle[i-1][j-1],triangle[i-1][j]);
triangle[i][i]+=triangle[i-1][i-1];
}

int sum=triangle[n-1][0];
for(int i=0;i<n;i++)
{
if(triangle[n-1][i]<sum)
sum=triangle[n-1][i];
}
return sum;

}
};

• 本文已收录于以下专栏：

## 【leetcode】120. Triangle

Difficulty：medium Given a triangle, find the minimum path sum from top to bottom. Each step you m...

## [LeetCode]120.Triangle

【题目】 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adj...

## Leetcode[120]-Triangle

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

## <LeetCode OJ> 120. Triangle

120. Triangle My Submissions Question Total Accepted: 62741 Total Submissions: 213503 Difficulty...

## LeetCode: Triangle [120]

【题目】 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adja...

## LeetCode 120. Triangle

1. 题目描述 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to ...

## [leetcode]120. Triangle(Java)

https://leetcode.com/problems/triangle/#/description Given a triangle, find the minimum pat...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)