Largest Fibonacci Subsequence
Easy Accuracy: 62.99% Submissions: 1720 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
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)



We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


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


All Submissions

My Submissions:

Login to access your submissions.

Largest Fibonacci Subsequence

Output Window