70. Climbing Stairs

You climb a staircase of n steps, taking 1 or 2 steps at a time. In how many distinct ways can you reach the top?

Example 1

Input: n = 2
Output: 2

Example 2

Input: n = 3
Output: 3
Hint 1

The last move is 1 step or 2 steps, so ways(n) = ways(n−1) + ways(n−2).

Hint 2

That is the Fibonacci recurrence; keep only two variables.

Dynamic Programming