MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / minFallingPathSum

Method minFallingPathSum

Array/MinimumFallingPathSum.py:39–52  ·  view source on GitHub ↗

:type A: List[List[int]] :rtype: int

(self, A)

Source from the content-addressed store, hash-verified

37"""
38class Solution(object):
39 def minFallingPathSum(self, A):
40 """
41 :type A: List[List[int]]
42 :rtype: int
43 """
44
45 for y in range(1, len(A)):
46 for x in range(len(A[0])):
47 a = A[y-1][x-1] if x-1 >= 0 else float('inf')
48 b = A[y-1][x+1] if x+1 < len(A[0]) else float('inf')
49
50 A[y][x] += min(A[y-1][x], a, b)
51
52 return min(A[-1])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected