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 64c2bdf commit 2ac98aeCopy full SHA for 2ac98ae
1 file changed
climbing-stairs/hjeomdev.java
@@ -0,0 +1,18 @@
1
+class Solution {
2
+ List<Integer> list = new ArrayList<>();
3
+ public int climbStairs(int n) {
4
+ list.add(0);
5
+ list.add(1);
6
+ list.add(2);
7
+ return step(n);
8
+ }
9
+
10
+ public int step(int n) {
11
+ if (list.size() > n && list.get(n) != null) {
12
+ return list.get(n);
13
14
+ int result = step(n - 1) + step(n - 2);
15
+ list.add(result);
16
+ return result;
17
18
+}
0 commit comments