s4553711
6/3/2017 - 3:41 PM

70.cpp

  class Solution {
public:
    int climbStairs(int n) {
        if (n <= 1) return 1;
        int prev = 1, cur = 1;
        for(int i=2; i<=n; i++) {
            int tmp = cur;
            cur += prev;
            prev = tmp;
        }
        return cur;
    }
};