package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev
# README
746. Min Cost Climbing Stairs
Solution idea
DP
- Definition
dp[i] = min cost to reach i-th cell ending at i
- Base Cases
dp[0] = cost[0]
dp[1] = cost[1]
- Recurrence
dp[i] = min(dp[i-1], dp[i-2]) + cost[i]
Time complexity = $O(n)$, Space complexity = $O(n)$