My 1ms C code solution


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

    }


Log in to reply
 

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