Given an array of integers, determine for each number whether it is a Fibonacci number.
For every element in the array:
Yes.No.The Fibonacci sequence is:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
n representing the size of the array.arr of n integers.For each element of the array, print:
Yes
if it is a Fibonacci number, otherwise:
No
Input:
arr = [2, 4, 8, 10, 13]
Checking each number:
2 → Yes
4 → No
8 → Yes
10 → No
13 → Yes
Output:
Yes No Yes No Yes
Input:
arr = [0, 1, 7, 21]
Output:
Yes Yes No Yes
1 ≤ n ≤ 10^5
0 ≤ arr[i] ≤ 10^18
Goal: Efficiently determine whether each number is a Fibonacci number without generating the entire Fibonacci sequence for every element.
Expert in Data Structures & Algorithms. Building tools to help developers crack FAANG interviews.
Schlumbergera • Pending
Schlumbergera • Pending
Schlumbergera • Pending
Willingness • Pending
Willingness • Pending