```
class Solution {
public:
int climbStairs(int n) {
int ans = 0;
if(n < 3)
ans = n;
else
{
vector<int> num(n, 0);
num[0] = 1;
num[1] = 2;
for(int i = 2; i < n; ++i)
{
num[i] = num[i - 1] + num[i - 2];
}
ans = num[n - 1];
}
return ans;
}
};
```