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

Running will execute all 3 cases.