Skip to content

Commit

Permalink
Add: #7 정수 삼각형 - 유이서
Browse files Browse the repository at this point in the history
  • Loading branch information
yuiseo authored Dec 11, 2024
1 parent 66e3dcc commit 29e4247
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dp/정수 삼각형/유이서.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import copy
def solution(triangle):
dp = copy.deepcopy(triangle)
for i in range(1,len(dp)):
for j in range(i+1):
if j==0:
dp[i][j] += dp[i-1][j]
elif j==i:
dp[i][j] += dp[i-1][j-1]
else:
dp[i][j] += max(dp[i-1][j-1], dp[i-1][j])

return max(dp[len(dp)-1])

0 comments on commit 29e4247

Please sign in to comment.