Quant Memo
Coding/●●●●

Largest rectangle in a histogram

Given bar heights of unit width, find the area of the largest rectangle that fits entirely under the skyline. A rectangle of height h can extend left and right as far as bars of height at least h continue.

heights = [2,1,5,6,2,3]  ->  10

Return the largest rectangle area. Aim for O(n)O(n) time.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions