FastPrepLargest Rectangle in Histogram
Problems/Largest Rectangle in Histogram

Largest Rectangle in Histogram

Bloomberg LP logoBloomberg LP● HardNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a firsthand Bloomberg new-grad virtual-onsite interview. Our version follows the standard Largest Rectangle in Histogram exercise.

Given an integer array heights representing a histogram, where every bar has width 1, return the area of the largest rectangle that can be formed using one or more consecutive bars.

Function

largestRectangleArea(heights: int[]) → int

Examples

Example 1

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

The bars of heights 5 and 6 form a rectangle of height 5 and width 2.

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, so no positive-area rectangle exists.

Constraints

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

More Bloomberg LP Onsite Interview questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Trapping Rain WaterTeradata · ONSITE INTERVIEW
  • Count Visible People to the LeftGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Construct a Tree from Level-Order and Inorder TraversalsSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Largest Rectangle in HistogramTekion · ONSITE INTERVIEWTekion interview questions
  • Trapping Rain WaterAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Trapping Rain WaterKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Confirmed Profiling Events with First-Observed StartsAnthropic · PHONE SCREEN · ONSITE INTERVIEWAnthropic interview questions
  • Trapping Rain WaterNuro · ONSITE INTERVIEWNuro interview questions
  • Trapping Rain WaterMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Trapping Rain WaterRupeek · ONSITE INTERVIEW

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int largestRectangleArea(int[] heights) {
        // Write your code here.
    }
}
Checking account…