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).

Note:
Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle.

1 class Solution {
2 public:
3     int minimumTotal(vector<vector<int> > &triangle) {
4         // Start typing your C/C++ solution below
5         // DO NOT write int main() function
6         
7     }
8 };
答题模板

相关文章:

  • 2022-02-19
  • 2021-12-15
  • 2022-12-23
  • 2021-07-18
  • 2021-11-21
  • 2021-05-29
  • 2021-10-20
  • 2021-09-11
猜你喜欢
  • 2022-01-01
  • 2021-08-23
  • 2021-08-18
  • 2021-05-31
  • 2021-07-22
  • 2021-07-06
  • 2021-10-31
相关资源
相似解决方案