Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def minFallingPathSum(self, A: List[List[int]]) -> int:
- n = len(A)
- for i in range(1, n):
- for j in range(n):
- center = A[i-1][j]
- left = A[i-1][j-1] if j > 0 else center
- right = A[i-1][j+1] if j < n - 1 else center
- A[i][j] += min(left, center, right)
- return min(A[n-1])
Advertisement
Add Comment
Please, Sign In to add comment