【leetcode】剑指 Offer 47. 礼物的最大价值
int maxValue(int** grid, int gridSize, int* gridColSize){ int i, j, temp1, temp2; for(i=gridSize-1; i>=0; i--){ for(j=gridColSize[i]-1; j>=0; j--){ temp1=(i+1<gridSize)?grid[i+1][j] :0; temp2=(j+1<gridColSize[i])?grid[i][j+1] :0; grid[i][j]+=fmax(temp1,temp2); } } return grid[0][0]; }