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的思想基本一致。

posted on 2019-12-15 01:28  Sempron2800+  阅读(221)  评论(0编辑  收藏  举报