N-th Fibonacci Number

Given n, return the n-th Fibonacci number where F(0)=0 and F(1)=1. Pattern focus: Climbing stairs. The same recurrence appears in many staircase counting problems, making this a pure linear DP warm-up.

Input Format

n = Fibonacci index

Output Format

the n-th Fibonacci number

Constraints

  • 0 <= n <= 45

Examples

Example 1:

Input:

n = 0

Output:

0

Explanation:

F(0) is defined as 0.

Example 2:

Input:

n = 7

Output:

13

Explanation:

The sequence is 0,1,1,2,3,5,8,13.

Loading...
N-th Fibonacci Number - Dp 1d DSA Problem