Skip to main content

Climbing Stairs

Learn Climbing Stairs (Dynamic Programming, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

How Many Ways to Climb N Stairs, 1 or 2 Steps at a Time? The number of ways to reach step n equals ways to reach n-1 (then take 1 step) PLUS ways to reach n-2 (then take 2 steps) - literally the Fibonacci recurrence in disguise. Bottom-up DP builds this from the base cases upward, O(n) time, O(1) space.

More lessons in Dynamic Programming