1,Triangle
1 int mininumTotal(vector<vector<int>>& triangle) { 2 for (int i = triangle.size() - 2; i >= 0; --i) { 3 for (int j = 0; j < i + 1; ++j) { 4 // 从下往上依次保存当前路径的最小值,上层只会用到下层的最小值 5 triangle[i][j] += min(triangle[i + 1][j], triangle[i + 1][j + 1]); 6 } 7 } 8 return triangle[0][0]; 9 }triangle