CodePark/ problems / Climbing Stairs
START PRACTICINGPRACTICE
Coding problem · Data structures and algorithms › Dynamic programming

Climbing Stairs

easyabout 10 minutes in an interview

You stand at the bottom of n stairs. In one move you go up 1 stair or 2 stairs. Count every possible list of moves that lands you exactly on the top stair, and return that count.

  • The order of moves matters: 1 then 2 is not the same as 2 then 1.
  • n is between 1 and 45, so the count fits in a normal number.
Input: n = 4 Output: 51+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2
Input: n = 2 Output: 21+1 or 2
Input: n = 1 Output: 1