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

A backward solution for c++ with 0ms.