← Back
🪜 Stairway of Recursion
Climb with 1 or 2 steps • See the recursion tree • Optimize with DP
Total Stairs:
🎮 Interactive
🌳 Recursion
🧠 Memoization
📊 Tabulation
🎮 Interactive Staircase
📐 DP Formula
dp[i] = dp[i-1] + dp[i-2]
Ways to reach step i =
(Ways to i-1) + (Ways to i-2)
Current Step
0
Total Ways
-
Calls Made
0
Cache Hits
0
Answer
?
▶ Start
Speed:
💻 Code
// Climbing Stairs DP
function
climb
(n) {
const
dp = [
1
,
1
];
for
(
let
i=
2
; i<=n; i++) dp[i] = dp[i-
1
] + dp[i-
2
];
return
dp[n]; }
💡 Insight
At each step, you can take either 1 or 2 stairs. This creates a recursive structure similar to Fibonacci!