Hard · Arrays

Max rectangle in histogram

Given an array heights of non-negative bar heights, each bar 1 unit wide, return the area of the largest rectangle that fits inside the histogram.

Examples

Example 1

[2,1,5,6,2,3]

Output: max area 10

Example 2

[2,4]

Output: max area 4

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Arrays problems