Climbing Stairs
這題是個斐波那契數列,規律很好找,不過dfs這題也可以解,就是不知道會不會TLE
class Solution {
public:
int a[1000];
int climbStairs(int n) {
a[0] = 1;
a[1] = 1;
for( int i = 2; i <= 1000; i++ )
a[i] = a[i-1]+a[i-2];
return a[n];
}
};
相關文章
- 70. Climbing StairsAI
- Leetcode Climbing StairsLeetCodeAI
- 746. Min Cost Climbing StairsAI
- Leetcode-Climbing StairsLeetCodeAI
- Climbing Stairs leetcode javaAILeetCodeJava
- 爬樓梯(LintCode Climbing Stairs)AI
- Leetcode-Easy 70. Climbing StairsLeetCodeAI
- Climbing Stairs 爬樓梯問題,每次可以走1或2步,爬上n層樓梯總方法 (變相fibonacci)AI
- [CareerCup] 9.1 Climbing Staircase 爬樓梯AI