Skip to content

Commit 4639059

Browse files
solves climbing stairs
1 parent 808198b commit 4639059

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: src/ClimbingStairs.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class ClimbingStairs {
2+
private static final int[] result = new int[50];
3+
4+
static {
5+
result[0] = result[1] = 1;
6+
for (int index = 2 ; index < result.length ; index++) {
7+
result[index] = result[index - 1] + result[index - 2];
8+
}
9+
}
10+
11+
public static int climbStairs(int steps) {
12+
return result[steps];
13+
}
14+
}

0 commit comments

Comments
 (0)