class Solution {
public int getMaxValue(int[][] grid) {
int n=grid.length,m=grid[0].length;
for (int i=0;i<n;i++){
for (int j=0;j<m;j++){
if(i==0&&j!=0){
grid[i][j]+=grid[i][j-1];
continue;
}
if(j==0&&i!=0){
grid[i][j]+=grid[i-1][j];
continue;
}
if(j==0&&i==0){
continue;
}
grid[i][j]+=Math.max(grid[i-1][j],grid[i][j-1]);
}
}
return grid[n-1][m-1];
}
}