leetcode931

1 class Solution(object):
2     def minFallingPathSum(self, A):
3         while len(A) >= 2:
4             row = A.pop()            
5             for i in range(len(row)):
6                 A[-1][i] += min(row[max(0,i-1): min(len(row), i+2)])
7         return min(A[0])

leetcode1289的基础版本,与leetcode120的思想基本一致。

猜你喜欢

转载自www.cnblogs.com/asenyang/p/12041732.html
今日推荐