We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8649a12 commit 15c0d42Copy full SHA for 15c0d42
solution/0120.Triangle/Solution2.cpp
@@ -0,0 +1,12 @@
1
+class Solution {
2
+public:
3
+ int minimumTotal(vector<vector<int>>& triangle) {
4
+ vector<int> dp(triangle.back()) ;
5
+
6
+ for (int i = triangle.size()-2; i >= 0; --i)
7
+ for (int j = 0; j <= i; ++j)
8
+ dp[j] = triangle[i][j] + min(dp[j], dp[j+1]) ;
9
10
+ return dp[0] ;
11
+ }
12
+};
0 commit comments