Showing:
Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Maximum Product of Increasing Subsequence of Size 3
Medium Accuracy: 10.9% Submissions: 768 Points: 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 "-1".

The task is to complete the function maxProductSubsequence() which finds maximum product of increasing subsequence of size 3. You should store answer in res array.

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

Example:
Input:

3
8
6 7 8 1 2 3 9 10
4
3 4 2 1
6
1 2 20 10 11 12

Ouput:
8 9 10
-1
10 11 12

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