Climbing stairs
easy 15 minClimbing stairs asks how many different sequences of 1-steps and 2-steps reach stair n.
Where it shows up
The same pattern appears across everyday software.
Rhythm in Sanskrit poetry
Indian prosodists, from Pingala to Virahanka and Hemachandra, counted the metres of a fixed length built from short syllables (1 beat) and long ones (2 beats). The count is exactly the climbing stairs number, centuries before Fibonacci wrote about rabbits.
Decoding messages
When digits map to letters (1 = A ... 26 = Z), a digit string can be read one or two digits at a time. Counting the possible readings, as in error-checking or puzzle tools, is climbing stairs with some moves forbidden.
Tiling and packing
Laying 1 × 2 tiles along a 2 × n strip, or filling a time slot with tasks of length 1 and 2, has ways(n) arrangements. Layout and scheduling tools use the same recurrence to count or enumerate options.
Counting moves in games and robots
A board-game piece or a robot that can advance 1 or 2 cells per turn reaches cell n in ways(n) different move sequences. Planners use the count to size search spaces before exploring them.
The standard first DP exercise
Courses and interview loops use climbing stairs to teach the DP recipe: define the state, find the recurrence from the last decision, set base cases, choose top-down or bottom-up, then reduce the space.