Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 227b80f

Browse files
Create 931.py
1 parent f0a2e2b commit 227b80f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎501-1000/931.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def minFallingPathSum(self, arr: List[List[int]]) -> int:
3+
for i in range(1,len(arr)):
4+
for j in range(len(arr[0])):
5+
if j==0:
6+
arr[i][j] += min([arr[i-1][j+1], arr[i-1][j]])
7+
elif j==len(arr[0])-1:
8+
arr[i][j] += min([arr[i-1][j-1], arr[i-1][j]])
9+
else:
10+
arr[i][j] += min([arr[i-1][j-1], arr[i-1][j], arr[i-1][j+1]])
11+
return min(arr[-1])

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /