class Solution {
public:
int climbStairs(int n) {
vector<int> table;
table.push_back(0);
table.push_back(1);
table.push_back(2);
if(n<=2)
return table[n];
for(int i=3;i<=n;i++)
{
table.push_back(table[i-1]+table[i-2]);
}
return table[n];
}
};
leetcode:Climbing Stairs
最新推荐文章于 2020-06-13 21:54:39 发布