TLE for python solution that should work?


  • 0
    B

    This is my solution and for some reason it shows Time limit exceeded. Can someone tell me what's wrong?

    def climbStairs(n):
        lookup = {1:1, 2:2}
            
                if n not in lookup:
                    lookup[n] = self.climbStairs(n-1) + self.climbStairs(n-2)    
                return lookup[n]
    

Log in to reply
 

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