0 ms C solution (dynamic programming)


  • 0
    int climbStairs(int n) {
        int a = 1, b = 2;
        int i = 1;
        while(i++ < n) {
            b += a;
            a = b - a;
        }
        return a;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.