64. Minimum Path Sum文章来源地址https://www.toymoban.com/news/detail-768149.html
class Solution:
def minPathSum(self, grid: List[List[int]]) -> int:
# grid=[[0 for i in range(len(grid[0]))]]+grid
# print(grid)
# return 21
n=len(grid[0])
for i in range(len(grid)):
if i==0:
for j in range(1,n):
grid[i][j]+=grid[i][j-1]
else:
for j in range(n):
if j==0:
grid[i][j]+=grid[i-1][j]
else:
grid[i][j]+=min(grid[i-1][j],grid[i][j-1])
return grid[len(grid)-1][n-1]
文章来源:https://www.toymoban.com/news/detail-768149.html
到了这里,关于64. Minimum Path Sum的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!