Skip to content

Commit 8175937

Browse files
author
MJ Kang
committed
Climbing Stairs DaleStudy#230
1 parent 219acf4 commit 8175937

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

climbing-stairs/mandoolala.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def climbStairs(self, n: int) -> int:
3+
if n == 1:
4+
return 1
5+
if n == 2:
6+
return 2
7+
dp = [0]*n
8+
dp[0] = 1
9+
dp[1] = 2
10+
for i in range(2, n):
11+
dp[i] = dp[i-1] + dp[i-2]
12+
return dp[n-1]

0 commit comments

Comments
 (0)