BETA

Difficulty Level: Medium

Submissions: 5026 Accuracy:

42.84%

Maximum Rectangular Area in a Histogram

Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars have same width and the width is 1 unit.

 

Input:
The first line contains an integer 'T' denoting the total number of test cases. In each test cases, the first line contains an integer 'N' denoting the size of array. The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array. The elements of the array represents the height of the bars.


Output:
In each seperate line the maximum rectangular area possible from the contigous bars.


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


Example:
Input: 
1
7
6 2 5 4 5 1 6

Output:
12

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