# Leetcode 509. Fibonacci Number ###### tags: `Leetcode(C++)` 題目 : https://leetcode.com/problems/fibonacci-number/submissions/ 。 想法 : 建表找。 時間複雜度 : O(n)。 程式碼 : ``` class Solution { public: int fib(int n) { int f[40]; f[0]=0; f[1]=1; for(int i=2 ; i<=n ; i++){ f[i]=f[i-1]+f[i-2]; } return f[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