Geeksforgeeks

Error

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.
```

```
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<=10^{3}

1<=A[]<=10^{9}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login 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?

YesLoading...

Largest Fibonacci Subsequence

...