Largest Histogram Plot Problem

Largest Histogram Plot Problem — ExecCode Hard DSA Practice

Solve the Largest Histogram Plot problem on ExecCode. Free online hard DSA practice in Stacks & Queues. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are given bar heights of a histogram standing on a common baseline. Any contiguous group of bars can form a rectangle whose height is limited by the shortest bar in that group. Hard OA variants ask for the maximum such area in linear time; nested loops fail hidden n≈10^4+ cases. Return the largest rectangular area that fits entirely inside the histogram. You are given: heights — array of non-negative bar heights, each bar has width 1 Return a single integer area. A zero-height bar splits the histogram. The answer may use a single bar.

Examples

Input {'heights': [2, 1, 5, 6, 2, 3]}; Output 10. Input {'heights': [2, 4]}; Output 4. Input {'heights': [0, 0, 0]}; Output 0

Constraints

0 <= heights[i]

Practice Largest Histogram Plot free on ExecCode. Browse DSA problems, topic map, and placement guides.