← Practice · Dynamic programming

Climbing Stairs Easy

You are climbing a staircase with n steps. Each move you can climb 1 or 2 steps. Return the number of distinct ways to reach the top.

Examples

  • n = 2 -> 2 (1+1, 2)
  • n = 3 -> 3 (1+1+1, 1+2, 2+1)

Define a function named climbStairs in JavaScript.

00:00▶ Visualize

JavaScript · Tab indents · Ctrl/⌘+Enter runs the tests