Skip to content

Commit 39e61b9

Browse files
author
jinbeom
committed
Climbing Stairs Solution
1 parent abce85a commit 39e61b9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

climbing-stairs/kayden.py

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

0 commit comments

Comments
 (0)