Open cjql opened 4 years ago
class Solution: def minFallingPathSum(self, A: List[List[int]]) -> int: dp = A[0] for row in A[1:]: dp = [value + min([dp[c], dp[max(c - 1, 0)], dp[min(len(A) - 1, c + 1)]]) for c, value in enumerate(row)] return min(dp)
C++
Java
Python
C
C
JavaScript
Ruby
Swift
Go
Scala
Kotlin
Rust
PHP