We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2cb3699 commit fbffa7eCopy full SHA for fbffa7e
1 file changed
climbing-stairs/heypaprika.py
@@ -0,0 +1,19 @@
1
+"""
2
+복잡도 : 예상 -> 예상한 이유
3
+
4
+시간 복잡도 : O(n) -> 배열의 길이 n-2 만큼 반복하므로
5
+공간 복잡도 : O(n) -> n 길이의 배열 하나를 생성하므로
6
7
+class Solution:
8
+ def climbStairs(self, n: int) -> int:
9
+ if n == 1:
10
+ return 1
11
+ elif n == 2:
12
+ return 2
13
+ a = [0] * n
14
+ a[0] = 1
15
+ a[1] = 2
16
+ for i in range(2, n):
17
+ a[i] = a[i-1] + a[i-2]
18
+ return a[n-1]
19
0 commit comments