70. Climbing Stairs
You can climb 1 or 2 steps at a time. Given n steps, how many distinct ways are there to reach the top?
def climb_stairs(n):
one, two = 1, 1
for _ in range(n - 1):
one, two = one + two, one
return one
The number of ways to reach step n is the ways to reach step n-1 plus the ways to reach step n-2 -- the Fibonacci recurrence in disguise. Only the last two values are ever needed, so there's no need for a full array.