Given n, return the n-th Fibonacci number. Pattern focus: Linear Recurrence DP. This is the simplest example of a state that depends on a fixed number of previous states.
n = Fibonacci index
the n-th Fibonacci number
Example 1:
Input:
n = 0
Output:
0
Explanation:
F(0) is 0.
Example 2:
Input:
n = 7
Output:
13
Explanation:
The sequence is 0,1,1,2,3,5,8,13.