My Python Solution


  • 0
    C
    class Solution(object):
        def climbStairs(self, n):
            if n < 4:
                return n
    
            pfirst = 1
            psecond = 1
            all_ways = 3
            for i in range(4,n+1):
                pfirst,psecond = pfirst+psecond,pfirst
                all_ways += pfirst
    
            return all_ways
    

Log in to reply
 

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