乐趣区

关于go:Leetcode专题数组70爬楼梯

leetcode 链接:
https://leetcode.cn/problems/climbing-stairs/solutions/270926…
解题思路:动静布局

func climbStairs(n int) int {dp := make([]int, n+1)
    dp[0] = 1
    dp[1] = 1
    for i := 2; i < len(dp); i++ {dp[i] = dp[i-2] + dp[i-1]
    }
    return dp[n]
}
退出移动版