One have to find the longest subarray such that its element
satisfies the following condition:
x[i]=x[i‐ 1]+x[i-2]
If more than
one subarray of is found of maximum length one has to print the array which
starts with the minimum element and if they are also same then the array with
minimum second element and so on. If
no subarray is found one has to print ‐1.
Input:
3, 5, 8, 2,
19, 12, 7, 11
Output:
2, 5, 7, 12, 19
No comments:
Post a Comment