We’re preparing your current view and syncing the latest data.
You are given an array of integers heights representing the histogram's bar height where the width of each bar is 1. Find the area of the largest rectangle in the histogram.
Example: heights = [2,1,5,6,2,3] Output: 10
The largest rectangle is formed by bars with heights 5 and 6, width 2, area 10.
An integer array heights where heights[i] represents the height of the ith histogram bar.
Return a single integer representing the area of the largest rectangle in the histogram.
1 <= heights.length <= 10^5 0 <= heights[i] <= 10^4
Example 1
Input
[2,1,5,6,2,3]
Output
10
Explanation
Largest rectangle is formed between bars with heights 5 and 6 with width 2 resulting in area 10.