Classic example
Input
heights = [2,1,5,6,2,3]
Output
10
The largest rectangle has area 10 using heights 5 and 6 (width 2, height 5).
Full lesson preview
Given bar heights of a histogram, compute the area of the largest rectangle that can be formed.
Problem statement
Task
Examples
Input
heights = [2,1,5,6,2,3]
Output
10
The largest rectangle has area 10 using heights 5 and 6 (width 2, height 5).
Input format
Output format
Constraints
Samples
Input
[2,4]
Output
4
Two bars, max area is 2*2 = 4 choosing both bars with min height 2.