← All problems

Climbing Stairs

Easy dynamic programmingmath LeetCode ↗
You are climbing a staircase with n steps; each move you may climb 1 or 2 steps. Count the number of distinct ways to reach the top. Recognize the recurrence before coding.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(1)

Common pitfalls

  • Exponential recursion without memo
  • Off-by-one base cases

Your solution

Log in to save your code and track progress.