Skip to content

Commit d35392f

Browse files
committed
climb stairs
1 parent 20b652f commit d35392f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

climbing-stairs/Sung-Heon.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def climbStairs(self, n: int) -> int:
3+
temp = {}
4+
if n == 1:
5+
return 1
6+
if n == 2:
7+
return 2
8+
temp[1] = 1
9+
temp[2] = 2
10+
a = 2
11+
while a != n:
12+
a += 1
13+
temp[a] = temp[a - 1] + temp[a - 2]
14+
return temp[a]
15+

0 commit comments

Comments
 (0)