classSolution: defclimbStairs(self, n): # if n == 0: # return 0 # if n == 1: # return 1 # if n == 2: # return 2 # steps = self.climbStairs(n-1)+self.climbStairs(n-2) # left = 0 # 超时 right = 0 result = 1 for i in range(n): left = right right = result result = left+right