斐波那契数列;
1 class Solution { 2 public: 3 int climbStairs(int n) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 if (n <= 0) { 7 return 0; 8 } 9 vector<int> fb(n + 1, 1); 10 fb[2] = 2; 11 for (int i = 3; i <= n; ++i) { 12 fb[i] = fb[i - 1] + fb[i - 2]; 13 } 14 return fb[n]; 15 } 16 };