python code in short


  • 0
    class Solution(object):
        def climbStairs(self, n):
            """
            :type n: int
            :rtype: int
            """
           
            ways=[1,2];
            
            for i in range(2,n):
                ways.append(ways[i-1]+ways[i-2])
             
            return ways[n-1]
    

Log in to reply
 

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