Notice Period

Stairway Counts

easy

A lighthouse keeper climbs the same spiral staircase every evening — n steps to the lamp room. To keep it interesting, each move she takes either 1 or 2 steps.

She wonders: how many distinct sequences of moves reach the top? Return that count for a given n.

Example 1
in n = 2
out 2
1+1 or a single 2-step.
Example 2
in n = 3
out 3
1+1+1, 1+2, 2+1.
Constraints
  • · 1 <= n <= 45
similar problem on LeetCode ↗
solution.pyloading python…
test results
Hit ▶ Run to test your code against the visible cases.