Fibonacci Number

Easy
math dynamic-programming recursion
Problem Description

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.

Input Format
A single integer n
Output Format
The nth Fibonacci number
Constraints
0 <= n <= 30
Sample Input/Output
Input:
4
Output:
3
Explanation

F(4) = F(3) + F(2) = 2 + 1 = 3.

Solution Hints
  • Read carefully: Understand input/output format and constraints
  • Start simple: Think of brute force solution first, then optimize
  • Edge cases: Consider empty inputs, single elements, max constraints
  • Data structures: Choose arrays, hash maps, sets based on problem needs
  • Time complexity: Ensure your solution fits within time limits
  • Test examples: Verify logic with provided sample inputs
80
Points
2000ms
Time Limit
256MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback