Z24
Largest Rectangle in Histogram
Problem Statement & Objective
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.
Function Signature (Python)
largest_rectangle_in_histogram(heights: list[int]) -> intInput & Output Contract
Output Rule:Maksimum alan (tam sayı).
System Constraints
1 <= yukseklikler.length <= 10^5
0 <= yukseklikler[i] <= 10^4Example Execution Walkthrough
yukseklikler = [2, 1, 5, 6, 2, 3] -> 5 ve 6 çubukları ile 5 * 2 = 10 -> cevap: 10Example Test Scenarios (3)
Example 1
Input:
[[2,1,5,6,2,3]]Expected Output:
10Example 2
Input:
[[2,4]]Expected Output:
4Example 3: Tek Çubuk
Input:
[[1]]Expected Output:
1