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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Arrays problems