class Solution {
public:
/**
* @param n: An integer
* @return: An integer
*/
int climbStairs(int n) {
if(n <= 1)
return 1;
if(n ==2)
return 2;
int result;
int a = 1;
int b = 2;
for(int i = 3;i<=n;i++){
result = a + b;
a = b;
b = result;
}
return result;
}
};
原文:http://www.cnblogs.com/11111wzc0417/p/6522165.html