Maximum product
Submissions: 1448   Accuracy:

10.43%

  Difficulty: Easy   Marks: 2

Given an array A[] of n integers, the task is to find a subsequence of size k whose product is maximum among all possible k sized subsequences of given array.

Input:
First line consists of T test cases. First line of every test cases consists of N, denoting the number of elements in an array. Second line consists of elements of array.

Output:
Single line output, print the maximum possible product.

Constraints:
1<=T<=100
1<=N<=10000
1<=K<=N
1<=Ai<=1000

Example:
Input:

2
4 3
8 6 4 6 
7 3
10 2 3 8 1 10 4 
Output:
288
800

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

Contributor: Saksham Raj Seth
Author: saksham seth


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 ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.