BBarCumulus
Product

Product features · Maximum histogram rectangle

01

Review candidate spans in BarCumulus by tracing how the shortest bar limits each rectangle.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Maximum histogram rectangle

● ● ●BarCumulus●
A concrete starting point · Maximum histogram rectangle ×
def histogram_area(heights):
    heights = tuple(heights)
    if len(heights) > 256 or any(type(h) is not int or not 0 <= h <= 1000000 for h in heights):
        raise ValueError("height.range")
    stack, best = [], 0
    for i in range(len(heights) + 1):
        current = heights[i] if i < len(heights) else 0
        while stack and heights[stack[-1]] > current:
            height = heights[stack.pop()]
            start = stack[-1] + 1 if stack else 0
            best = max(best, height * (i - start))
        stack.append(i)
    return best
✳Find the largest rectangle beneath unit-width histogram bars with at most 256 integer heights from zero through 1000000.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗