four lines to solve the problem in python


  • 1
    L
        def climbStairs(self, n):
            """
            :type n: int
            :rtype: int
            """
            a=[1,2]
            for i in range(2,n):
                a.append(a[i-1]+a[i-2])
            return a[n-1]

Log in to reply
 

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