Largest Rectangle in Histogram
HardGiven an array of 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.
Example:
Input: heights = [2,1,5,6,2,3] Output: 10 Explanation: The largest rectangle is formed by heights [5,6] with width 2 (5*2=10). Input: heights = [2,4] Output: 4 Explanation: The largest rectangle is formed by the single bar of height 4.
Test Cases
Test Cases
Input
3 5 6 2 1 4
Expected Output
10
Step 1
Step 2
Step 3
Step 4
Step 1: Identify the Pattern
Largest Rectangle in Histogram
HardGiven an array of 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.
Example:
Input: heights = [2,1,5,6,2,3] Output: 10 Explanation: The largest rectangle is formed by heights [5,6] with width 2 (5*2=10). Input: heights = [2,4] Output: 4 Explanation: The largest rectangle is formed by the single bar of height 4.
Test Cases
Test Cases
Input
3 5 6 2 1 4
Expected Output
10
Step 1
Step 2
Step 3
Step 4
Step 1: Identify the Pattern
Study Notes
Start Taking Notes!
Create and organize your study notes for this problem. Keep track of your solutions and insights.