mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-04 16:12:47 +08:00
11 lines
167 B
Go
11 lines
167 B
Go
package leetcode
|
|
|
|
func climbStairs(n int) int {
|
|
dp := make([]int, n+1)
|
|
dp[0], dp[1] = 1, 1
|
|
for i := 2; i <= n; i++ {
|
|
dp[i] = dp[i-1] + dp[i-2]
|
|
}
|
|
return dp[n]
|
|
}
|