Problem Description
Given an array of integers A .
A represents a histogram i.e A[i] denotes height of the ith histogram's bar. Width of each bar is 1.
Find the area of the largest rectangle formed by the histogram.
1 <= |A| <= 100000
1 <= A[i] <= 1000000000
The only argument given is the integer array A.
Return the area of largest rectangle in the histogram.
Input 1:
A = [2, 1, 5, 6, 2, 3]
Input 2:
A = [2]
Output 1:
10
Output 2:
2
Explanation 1:
The largest rectangle has area = 10 unit. Formed by A[3] to A[4].
Explanation 2:
Largest rectangle has area 2.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.