You climb a staircase with n steps. Each time you can climb 1 or 2 steps. How many distinct ways to reach the top?
To reach step i you must have come from step i−1 (took 1 step) or step i−2 (took 2 steps). So total ways = ways(i−1) + ways(i−2). Same as Fibonacci. dp[1]=1 (one way: {1}), dp[2]=2 ({1,1} or {2}).
Listing every sequence of 1 and 2 steps grows exponentially. But the count for each step can be built from smaller counts.
Think about the very last move to step i. Either you came from step i −1 with a single step, or from step i minus 2 with a double step. So ways of i equals ways of i −1 plus ways of i minus 2. The base cases are 1 way to reach step 1, and 2 ways to reach step 2. It is the Fibonacci pattern in disguise.
Ask where the last move came from. The recurrence is the sum of the ways into the previous states.
Run the animation above on your own input, or watch the 1:31 video explanation of Climbing Stairs with a dry run and Java code.