Coding Challenge

Largest Rectangle in Histogram

Hard
stackmonotonic-stack

Find the largest rectangle area in a histogram.

Given bar heights of width 1, return the area of the largest rectangle that can be formed in the histogram.

Examples

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

Output: 10

Constraints

  • 1 <= heights.length

Preparing your coding workspace...