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

30:00

Largest Rectangle in Histogram
hard
Topics
Companies

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

Example 1:
Input: [2,1,5,6,2,3]
Output: 10
Constraints:
  • 1heights.length1051 \leq \text{heights.length} \leq 10^5

  • 0heights[i]1040 \leq \text{heights}[i] \leq 10^4

Input
arr =[2,1,5,6,2,3]

Start

2
0
1
1
5
2
6
3
2
4
3
5
Max Area

0

Stack (Indices)

[]

Variables
No variables to display
DepthFunction Call
Stack empty
0/26