Largest Rectangle in Histogram in Stacks and Queues
Largest Rectangle in Histogram in Stacks and Queues
histogram which mean the height of the ith bar will be Ai units and the width
Input Format
The first line of input will contain a single integer T , denoting the number
of test cases.
The first line of each test case contains an integer N - the length of the
array A.
The second line of each test case contains N space-separated integers
A1 , A2 , … , AN .
Output Format
For each test case, output on a new line the area of the largest rectangle in
the histogram.
Constraints
1 ≤ T ≤ 100
1 ≤ N ≤ 105
1 ≤ Ai ≤ 109
Subtasks
Subtask 1 (30 points): 1 ≤ N ≤ 1000
Subtask 2 (70 points): No further constraints.
Sample 1:
Input Output
3 12
4 15
https://www.codechef.com/learn/course/stacks-and-queues/LSTACKS02/problems/PREP22 1/1