爬楼梯
class Solution {
public:
/**
* @param n: An integer
* @return: An integer
*/
int climbStairs(int n) {
// write your code here
int dp1 = 1, dp2 = 2, dpWay = 0;
if (n <= 1) return dp1;
if (n == 2) return dp2;
while ((n--) - 2) {
dpWay = dp1 + dp2;
dp1 = dp2;
dp2 = dpWay;
}
return dpWay;
}
};