BETA

Difficulty Level: Easy

Submissions: 7683 Accuracy:

32.71%

Maximum Product Subarray
     

Given an array that contains both positive and negative integers, find the product of the maximum product subarray.
Assumption: There is always a positive product possible, i.e., no array of this form: {0,-20,0,0} or {-20}.

Input:
First line of input contain number of test cases T. First line of test case contain the size of array and second line of test case contain the array elements.

Output:
Maximum product of subarray is displayed to the user.

Constraints:
1 <=T<= 100
1 <=N<= 9
-10 <=arr[i]<= 10

Example:

Input:

3
5
6 -3 -10 0 2
6
2 3 4 5 -1 0 
10
8 -2 -2 0 8 0 -6 -8 -6 -1

Output:
180
120
288

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

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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