Skip to content

Commit 0bc32ec

Browse files
committed
feat: climbing-stairs 풀이
1 parent c00f407 commit 0bc32ec

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

climbing-stairs/jinah92.py

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

0 commit comments

Comments
 (0)