Maximum Product of Increasing Subsequence of Size 3
Submissions: 472   Accuracy:


  Difficulty: Medium   Marks: 4

Given a sequence of non-negative integers, find the subsequence of length 3 having maximum product, with the elements of the subsequence being in increasing order.

Input: The first line of input contains number of testcases T. Each testcase contains 2 lines, the first line contains N, the number of elements in array, and second line contains space separated elements of array.

Output: Print the subsequence of size 3 having maximum product, numbers of subsequence being in increasing order. If no such sequence exists, print "Not Present".

1 <= T <= 100
1 <= N <= 105
1 <= A[i] <= 105


6 7 8 1 2 3 9 10
3 4 2 1
8 9 10
Not present

Testcase 1:
3 increasing elements of the given arrays are 8, 9 and 10 which forms the subsequence of size 3 with maximum product.


** For More Input/Output Examples Use 'Expected Output' option **

Author: SIDG

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.