heights is a bar chart: bar i is heights[i] units tall and one unit wide, and the bars stand side by side with no gaps. Return the area of the biggest rectangle that fits entirely inside the bars.
A rectangle may span several neighbouring bars, but it can be no taller than the shortest bar it covers.
The bars 6, 5, 7 are all at least 5 tall, so a rectangle 5 high and 3 wide fits over them: 15. Taking the 2 as well would drop the height to 2 (area 8), and the tallest bar alone gives only 7.
A bar of height 0 splits the chart: nothing can stretch across it, so each 3 stands alone.
Constraints
1 <= heights.length <= 10⁵0 <= heights[i] <= 10⁴Every candidate rectangle is limited by its shortest bar. For each bar, ask: how wide could a rectangle exactly this tall stretch before a shorter bar stops it on either side?
15