Problems

Largest Rectangle in Histogram

hard
hard
arrays
stack

Given an array of integers heights representing the histogram's bar heights where the width of each bar is 1, return the area of the largest rectangle in the histogram.

Examples

Example 1

Input: heights = [2,1,5,6,2,3]
Output: 10

Example 2

Input: heights = [2,4]
Output: 4

Example 3

Input: heights = [2,1,2]
Output: 3
🔒 5 hidden

Running will execute all 8 cases, including 5 hidden ones.