class Solution {
public:
int minimumTotal(vector<vector<int>>& triangle) {
for(int i = triangle.size() - 2; i >= 0; --i){
for(int j = 0; j < i + 1; ++j){
triangle[i][j] += min(triangle[i + 1][j], triangle[i + 1][j + 1]);
}
}
return triangle[0][0];
}
};
class Solution {
public:
int maxSubArray(vector<int>& nums) {
int result = INT_MIN, f = 0;
for(int i = 0; i < nums.size(); ++i){
f = max(f + nums[i], nums[i]);
result = max(result, f);
}
return result;
}
};