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 8cc2f40 commit d7eaecbCopy full SHA for d7eaecb
1 file changed
climbing-stairs/Yu-Won.js
@@ -0,0 +1,22 @@
1
+/**
2
+ * 문제: https://leetcode.com/problems/climbing-stairs/description/
3
+ *
4
+ * 요구사항:
5
+ * n개의 계단이 있을 때
6
+ * 계단은 1, 2 칸씩 오를 수 있다.
7
+ * 이 계단을 오르는 방법은 총 몇가지 인가?
8
9
+ * * */
10
+
11
+const climbingStairs = (n) => {
12
+ if(n <= 1) return 1;
13
+ let prev1 = 1;
14
+ let prev2 = 1;
15
+ for(let i = 1; i < n; i++) {
16
+ let current = prev1 + prev2;
17
+ prev2 = prev1;
18
+ prev1 = current;
19
+ }
20
21
+ return prev1;
22
+}
0 commit comments