Skip to content

Commit

Permalink
Time: 0 ms (100%), Space: 5 MB (44.35%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Jan 15, 2025
1 parent d6a698c commit 61987a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 0120-triangle/0120-triangle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
func minimumTotal(triangle [][]int) int {
dp := make([]int, len(triangle) + 1)
for i := len(triangle) - 1; i >= 0; i-- {
for j, v := range triangle[i] {
dp[j] = v + min(dp[j], dp[j+1])
}
}

return dp[0]
}

0 comments on commit 61987a4

Please sign in to comment.