70. Climbing Stairs
Intuition
At any step, you can climb either 1 step or 2 steps. So, the number of ways to reach step n
is the sum of:
The number of ways to reach step
n - 1
(and then take 1 step)The number of ways to reach step
n - 2
(and then take 2 steps)
This is structurally identical to the Fibonacci sequence.
Complexity
Space Complexity
Time Complexity
Code
Last updated