cjql / algorithm

https://cjql.github.io/algorithm/
1 stars 1 forks source link

LeetCode_Dynamic: https://leetcode.com/problems/minimum-falling-path-sum/submissions/ #8

Open cjql opened 4 years ago

cjql commented 4 years ago

C++

Java

Python

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

C

JavaScript

Ruby

Swift

Go

Scala

Kotlin

Rust

PHP