# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param grid int整型二维数组 # @return int整型 # class Solution: def maxValue(self , grid: List[List[int]]) -> int: # write code here H = len(grid) W = len(grid[0]) dp =[[grid[i][j] for j in range(W)] for i in range(H)] for i in range(H): for j in range(W): if i >0: up = dp[i-1][j] else: up = 0 if j >0: left = dp[i][j-1] else: left = 0 dp[i][j] = dp[i][j]+max(up,left) return dp[H-1][W-1]