题目描述
blablabla
样例
blablabla
算法1
class Solution {
public:
int getMaxValue(vector<vector<int>>& grid) {
int n=grid.size(),m=grid[0].size();
for (int i=0;i<n;i++) {
for (int j=0;j<m;j++) {
if(i==0 && j==0) continue;
else if (i==0) grid[i][j]+=grid[i][j-1];
else if (j==0) grid[i][j]+=grid[i-1][j];
else grid[i][j]=max(grid[i-1][j],grid[i][j-1])+grid[i][j];
}
}
return grid[n-1][m-1];
}
};