Files
LeetCode-Go/leetcode/0070.Climbing-Stairs/70. Climbing Stairs.go
2020-08-07 17:06:53 +08:00

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]
}