AO
Back

Largest Rectangle Area in Histogram (Variant)

CodingOnsiteLast reported April 2026Low Frequency

Problem Overview

The round is one problem with one graded follow-up and one spoken one, on the onsite coding round. Two reports. Both candidates recognized the shape of a known histogram problem and both note the twist: it asks for the largest rectangle, not the smallest, and it is a points problem, not a bars problem. The interviewer stays quiet until you finish.

You are given points as [x, y] pairs. Find the largest-area axis-parallel rectangle whose four corners are all given points. Return 0 if none exists.

Given — the function to write

def max_rectangle_area(points: list[list[int]]) -> int: ...

Part 1 — the largest rectangle

Map each x to the set of its y values. For every pair of columns, intersect the two sets; any two shared y values form a rectangle of width times height. One candidate stalled on finding the shared y values efficiently before reaching for a set, and passed.

Part 2 — no other point inside

Reported follow-up: no other given point may lie inside the rectangle. Clarify the border before coding: the report says "inside", but the LeetCode problem it was compared to also forbids points on the border. Reject a candidate rectangle if a point lies strictly between its columns and rows (and, under the stricter reading, on its edges).

Discussion — rectangles that are not axis-parallel. The second follow-up was talk only, no code: treat each ordered pair of points as one side, derive the other two corners, and look them up.

The reported wall — the intersection. The enumeration is obvious; how you find common y values between two columns is where the time went.

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.

What Reports Emphasize

Common mistakes: Getting stuck on how to efficiently find common y-values between two columns — one candidate mentioned spending extra time here before settling on a set-based solution.

Interviewer hints: The interviewer was 'pretty quiet throughout' while the candidate coded, only beginning discussion after the solution was complete.; The second follow-up (non-axis-parallel rectangle) explicitly does not require implementation — discussion of approach is sufficient.

What passers do: Enumerating pairs of x-coordinates, finding common y-values between the two columns (using a set for efficiency), then computing the area. The candidate who passed noted getting stuck briefly on efficient common-y lookup but resolved it with a set approach.

Practice

Write your own against 5 test cases, or read the worked solution — approach, complexity, and code that runs.
Waymo · Coding · Reported 2× across candidate reports
Is this helpful?