Simplest solution using fibonacci concept


  • 1
    M

    public class Solution {
    public int climbStairs(int n) {

        int a = 1;
        int b = 1;
        int c = 1; 
        for(int i=2; i <= n; i++){
            c = a + b;
            a = b;
            b = c;
        }
        return c;
    
    }
    

    }


Log in to reply
 

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