-
-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path70.java
More file actions
33 lines (32 loc) · 996 Bytes
/
70.java
File metadata and controls
33 lines (32 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
__________________________________________________________________________________________________
sample 0 ms submission
class Solution {
Map<Integer, Integer> map = new HashMap();
public int climbStairs(int n) {
if (n == 0)
return 0;
if (n == 1)
return 1;
if (n == 2)
return 2;
if (map.get(n) == null)
map.put(n, climbStairs(n-1) + climbStairs(n-2));
return map.get(n);
}
}
__________________________________________________________________________________________________
sample 36024 kb submission
class Solution {
public int climbStairs(int n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
} else if (n == 2) {
return 2;
} else {
return climbStairs(n - 1) + climbStairs(n - 2);
}
}
}
__________________________________________________________________________________________________