Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@codeantik | 448 |

@SherlockHolmes3 | 447 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

Complete Leaderboard |

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"**.

**User Task:**

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** <= 10^{5}

1 <= **A[i]** <= 10^{5}

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

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?

Yes
Maximum Product of Increasing Subsequence of Size 3

...