Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5642
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4610
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Largest Fibonacci Subsequence
Easy Accuracy: 66.41% Submissions: 488 Points: 2

Given an array with positive number the task to find the largest subsequence from array that contain elements which are Fibonacci numbers.

 

Example 1:

Input : arr[] = {1, 4, 3, 9, 10, 13, 7}
Output : subset[] = {1, 3, 13}
The output three numbers are Fibonacci
numbers.
 
Example 2:
Input  : arr[] = {0, 2, 8, 5, 2, 1, 4,
                  13, 23}
Output : subset[] = {0, 2, 8, 5, 2, 1,
                    13, 23}



Your Task:  
You don't need to read input or print anything. Your task is to complete the function findFibSubset() which takes the array A[] and its size N as inputs and returns the  elements of the fibonacci subsequence in a vector. If no such number found return empty vector.


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


Constraints:
1<=N<=103
1<=A[]<=109

 

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.

Largest Fibonacci Subsequence

Output Window