noodleProblems/
Climbing Stairs
#77

Climbing Stairs

AlgorithmeasyMathDynamic ProgrammingMemoization

You are climbing a staircase with n steps. Each move you may climb either 1 or 2 steps.

Return the number of **distinct** ordered ways you can reach the top.

Example cases

  • two steps
    in n = 2
    out 2
    Either 1+1 or a single 2-step.
  • three steps
    in n = 3
    out 3
    1+1+1, 1+2, or 2+1.
  • one step
    in n = 1
    out 1

Constraints

  • 1 <= n <= 45
Saved
n =
2