AO
AceOffer
·
Back

Largest Rectangle Area in Histogram (Variant)

CodingPhone, OnsiteSoftware Engineer, Machine Learning EngineerLast reported April 2026Low Frequency

Problem Overview

A variant of the classic 'Largest Rectangle in Histogram' problem, but instead of finding the largest rectangle under a histogram (which uses a min-based approach), the task is modified to find the maximum area rectangle.
Full problem statement
A variant of the classic 'Largest Rectangle in Histogram' problem, but instead of finding the largest rectangle under a histogram (which uses a min-based approach), the task is modified to find the maximum area rectangle. Concretely: given a set of points or columns with y-values, enumerate pairs of x-coordinates, identify common y-values between those two columns, and compute the maximum rectangle area achievable. The problem is framed as finding the largest (not smallest) rectangle satisfying some geometric constraint among given coordinate data.

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Concurrency · 1Trade-off discussion · 1
Concurrency
How would you handle the case where the rectangle does not need to be axis-parallel?
Probes for: After handling the no-interior-points constraint
Trade-off discussion
What if no interior points are allowed inside the chosen rectangle?
Probes for: After solving the base problem

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Brute force column-pair scanCheck all y-values for every x-pair without a set; simpler to implement but slower due to lack of O(1) lookup for common y-values.

Practice

Open the editor to write a solution against test cases, then return here to compare against the follow-ups.
Open Editor →
Waymo · Coding · Reported 2× across candidate reports