import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param grid int整型二维数组 * @return int整型 */ public int maxValue (int[][] grid) { // write code here for(int i = 0;i < grid.length;i++){ for (int j = 0; j < grid[0].length;j++){ if(i == 0 && j == 0){ continue; } 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] += Math.max(grid[i][j-1], grid[i-1][j]); } } } return grid[grid.length-1][grid[0].length-1]; } }