题目描述
Given an array with positive integers, the task is to find the largest subsequence from the array which contains only 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}
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}
输入格式
见题面
输出格式
见题面