Climbing Stairs LeetCode solution in Python

1
class Solution(object):
2
def climbStairs(self, n):
3
"""
4
:type n: int
5
:rtype: int
6
"""
7
memo = {}
8
memo[1] = 1
9
memo[2] = 2
10

11
def climb(n):
12
if (
13
n in memo
14
): # if the recurssion already done before first take a look-up in the look-up table
15
return memo[n]
16
else: # Store the recurssion function in the look-up table and reuturn the stored look-up table function
17
memo[n] = climb(n - 1) + climb(n - 2)
18
return memo[n]
19

20
return climb(n)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0