Simple python 38ms


  • 0
    L
    class Solution:
        # @param {integer} n
        # @return {integer}
        def climbStairs(self, n):
            if n < 4:
                return n
            x1 = 2
            x2 = 3
            for i in range(n-3):
                x3 = x1 + x2
                x1 = x2
                x2 = x3
            return x3

Log in to reply
 

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