FastPrepLargest Rectangle in Histogram
Problems/Largest Rectangle in Histogram

Largest Rectangle in Histogram

Airwallex logoAirwallex● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names this well-known problem directly.

Our version is about 99% the same as the reported question.

You are given an integer array heights. It describes a histogram: a row of bars where every bar has width 1. Return the area of the largest rectangle you can form from one or more bars that sit next to each other.

Function

largestRectangleArea(heights: int[]) → int

Examples

Example 1

heights = [2,1,5,6,2,3]return = 10

The bars of heights 5 and 6 sit next to each other. Together they form a rectangle of height 5 and width 2. No rectangle is larger, so the answer is its area, ten.

Example 2

heights = [2,4]return = 4

The best area is 4, achieved either by the second bar alone or by both bars at height 2.

Example 3

heights = [0]return = 0

The only bar has height 0. No rectangle with a positive area exists, so the answer is zero.

Constraints

  • 1 <= heights.length <= 100000.
  • 0 <= heights[i] <= 10000.

More Airwallex interview questions

  • 4Sum Index QuadruplesPHONE SCREEN · Seen Sep 2026
  • Paginated K-Way Unique MergePHONE SCREEN · Seen Sep 2026
  • Maximal SquarePHONE SCREEN · Seen Aug 2026
  • Named Async Task SchedulerOA · Seen Oct 2026

Similar questions at other companies

  • Trapping Rain WaterBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Count Visible People to the LeftGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Trapping Rain WaterAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Confirmed Profiling Events with First-Observed StartsAnthropic · PHONE SCREEN · ONSITE INTERVIEWAnthropic interview questions
  • Rain Kept Between WallsDocuSign · PHONE SCREENDocuSign interview questions
  • Rain Water Held Between BarsAdobe · PHONE SCREENAdobe interview questions
  • Largest Rectangle in a HistogramDecagon · PHONE SCREENDecagon interview questions
  • Asteroid CollisionSiemens · PHONE SCREEN
  • Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions
  • Next Taller Building to the RightTemu · PHONE SCREENTemu interview questions
All Airwallex interview questionsSee Airwallex hiring insights
Saved
class Solution {
    public int largestRectangleArea(int[] heights) {
        // Write your code here.
    }
}
Checking account…