Climbing Stairs LeetCode solution in Python
1class Solution(object):2def climbStairs(self, n):3"""4:type n: int5:rtype: int6"""7memo = {}8memo[1] = 19memo[2] = 21011def climb(n):12if (13n in memo14): # if the recurssion already done before first take a look-up in the look-up table15return memo[n]16else: # Store the recurssion function in the look-up table and reuturn the stored look-up table function17memo[n] = climb(n - 1) + climb(n - 2)18return memo[n]1920return climb(n)