Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6376
@mb1973 5604
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Fibonacci in the array
Basic Accuracy: 43.58% Submissions: 296 Points: 1

Given an array arr of size N, the task is to count the number of elements of the array which are Fibonacci numbers

Example 1:

Input: N = 9, arr[] = {4, 2, 8, 5, 20, 1, 
                              40, 13, 23}
Output: 5
Explanation: Here, Fibonacci series will 
be 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. 
Numbers that are present in array are 
2, 8, 5, 1, 13

Example 2:

Input: N = 4, arr[] = {4, 7, 6, 25} 
Output: 0
Explanation: No Fibonacci number in 
this array.

 

Your Task:
This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function checkFib() that takes array arr and integer N as parameters and returns the desired output.

 

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

 

Constraints:
1 ≤ N ≤ 106

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Fibonacci in the array

Output Window