# Leetcode 70. Climbing Stairs ###### tags: `Leetcode(C++)` 題目 : https://leetcode.com/problems/climbing-stairs/ 。 想法 : Fibonacci數列換個方式。 時間複雜度 : O(n)。 程式碼 : ``` class Solution { public: int climbStairs(int n) { int stair[50]; stair[0]=1; stair[1]=1; for(int i=2 ; i<=n ; i++){ stair[i]=stair[i-1]+stair[i-2]; } return stair[n]; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up