Z24

Largest Rectangle in Histogram

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

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]) -> int

Input & Output Contract

Output Rule:Maksimum alan (tam sayı).

System Constraints

1 <= yukseklikler.length <= 10^5
0 <= yukseklikler[i] <= 10^4

Example Execution Walkthrough

yukseklikler = [2, 1, 5, 6, 2, 3] -> 5 ve 6 çubukları ile 5 * 2 = 10 -> cevap: 10

Example Test Scenarios (3)

Example 1
Input:[[2,1,5,6,2,3]]
Expected Output:10
Example 2
Input:[[2,4]]
Expected Output:4
Example 3: Tek Çubuk
Input:[[1]]
Expected Output:1
Loading Python Editor...
Input Parameters
[
  [
    2,
    1,
    5,
    6,
    2,
    3
  ]
]
Expected Output
10