```
class Solution {
public:
int climbStairs(int n) {
int dp1 = 1, dp2 = 2, dpRet = 0;
if (n <= 1) return dp1;
if (n == 2) return dp2;
int i = 3;
while (i++ <= n)
{
dpRet = dp1 + dp2;
dp1 = dp2;
dp2 = dpRet;
}
return dpRet;
}
};
```