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 532c978 commit be85556Copy full SHA for be85556
climbing-stairs/samthekorean.py
@@ -0,0 +1,18 @@
1
+# Time complexity : O(n)
2
+# Space complexity : O(n)
3
+class Solution:
4
+ def climbStairs(self, n: int) -> int:
5
+ a = 1
6
+ b = 2
7
+ result = 0
8
+ if n == 1:
9
+ return a
10
+
11
+ if n == 2:
12
+ return b
13
14
+ for i in range(3, n + 1):
15
+ result = a + b
16
+ a, b = b, result
17
18
+ return result
0 commit comments