Skip to content

Climbing Stairs

EasyDynamic Programming
Decode it first. Clues, constraints, pattern and plan before any code.

A staircase has n steps. Each move, you climb either 1 or 2 steps. Return how many different sequences of moves get you exactly to the top.

n = 2  →  2   (1+1, 2)
n = 3  →  3   (1+1+1, 1+2, 2+1)
n = 5  →  8

Constraints

  • 1 <= n <= 45