Resource · Guide or article
Recursive Staircase Problem
Counts the ways to climb n stairs taking one or two steps at a time, and uses the problem to contrast several programming paradigms.
Reviewed
Open the original: Recursive Staircase Problem (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
There are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 or 2 stairs at a time. Count the number of ways, the person can reach the top. This is an interesting problem because there are several ways of how it may be solved that illustrate different programming paradigms.
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Reference
What it covers
- Problem statement with an illustration
- Brute force recursion listed at O(2^n) time and O(1) space
- Memoized and DP versions both listed at O(n) time and O(n) space
- Iterative version listed at O(n) time and O(1) space
How to use it
PrepKit study advice, not a claim made by the source.
Write all four versions from memory, then explain why the iterative one needs only two variables.
Scope and limitations
The page lists solutions without explaining them; the reasoning is in the folder's JavaScript files and the linked video and article.
Access and format
Short README on GitHub, trekhleb/javascript-algorithms (MIT), linking four solution files. English, free.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/uncategorized/recursive-staircase/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.