java solution 0ms


  • 0
    3
            public int climbStairs(int n) {
      		int[] dp = {1,1};
    		for (int i = 2; i <= n; i++) {
    			dp[i%2] = dp[0] + dp[1];
    		}
    		return dp[n%2]; 
    	}
    

Log in to reply
 

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