Skip to content

Commit ebfbfe2

Browse files
committed
Time: 36 ms (46.91%) | Memory: 16.5 MB (20.69%) - LeetSync
1 parent 70b1df8 commit ebfbfe2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

70-climbing-stairs/climbing-stairs.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def climbStairs(self, n: int) -> int:
3+
map = {}
4+
def helper(n):
5+
6+
if n in map:
7+
return map[n]
8+
9+
if n == 0:
10+
return 0
11+
if n == 1:
12+
return 1
13+
if n == 2:
14+
return 2
15+
16+
ans = helper(n-1) + helper(n-2)
17+
map[n] = ans
18+
return map[n]
19+
return helper(n)
20+

0 commit comments

Comments
 (0)