Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Climbing Stairs
Bookmark
Input
n = 2
n = 3
n = 5
n = 8
n = 10
Custom
n
=
5
0
1
2
3
4
5
?
?
?
?
?
?
dp[i] = dp[i-1] + dp[i-2]
0
1
2
3
4
5
?
?
?
?
?
?
dp[i] = dp[i-1] + dp[i-2]
0
1
2
3
4
5
1
?
?
?
?
?
dp[0]
=
1
base case
0
1
2
3
4
5
1
1
?
?
?
?
dp[1]
=
1
base case
0
1
2
3
4
5
+1
+2
1
1
2
?
?
?
i
dp[2]
=
dp[1]
+
dp[0]
=
1
+
1
=
2
0
1
2
3
4
5
+1
+2
1
1
2
?
?
?
i
dp[3]
=
dp[2]
+
dp[1]
=
2
+
1
=
?
0
1
2
3
4
5
+1
+2
1
1
2
3
?
?
i
dp[3]
=
dp[2]
+
dp[1]
=
2
+
1
=
3
0
1
2
3
4
5
+1
+2
1
1
2
3
?
?
i
dp[4]
=
dp[3]
+
dp[2]
=
3
+
2
=
?
0
1
2
3
4
5
+1
+2
1
1
2
3
5
?
i
dp[5]
=
dp[4]
+
dp[3]
=
5
+
3
=
?
0
1
2
3
4
5
+1
+2
1
1
2
3
5
8
i
dp[5]
=
dp[4]
+
dp[3]
=
5
+
3
=
8
0
1
2
3
4
5
1
1
2
3
5
8
8 distinct ways
to climb 5 stairs
algo
master
.
io
Step:
Start: count the distinct ways to climb 5 stairs
0 / 11
Input
n = 2
n = 3
n = 5
n = 8
n = 10
Custom
n
=
5
0 / 11
algo
master
.
io
Step:
Start: count the distinct ways to climb 5 stairs