You are coding as a Guest. Sign in with your RoleNest account to permanently track your streak, earn XP, and climb the Campus Leaderboard!
Sign In with RoleNestProblem Set
🔥Largest Rectangle in Histogram: Monotonic Bar StackHard
SUPER HARD PROBLEM OF THE DAY+150 XP • FAANG OA TIER
High-difficulty challenge matching authentic Google, Amazon & Uber L5 online assessment conditions.
HardStack•Acceptance: 44.7%
Largest Rectangle in Histogram: Monotonic Bar Stack
Targeted in FAANG & Tech OA:GoogleAmazonMicrosoft
Real-World Engineering Context
Used in computer vision (optical character recognition, bounding box segmentation) and database query planning for maximal contiguous memory block allocators.
Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return the area of the largest rectangle in the histogram.
Sample Test Cases
Input: [[2,1,5,6,2,3]]
Expected: 10
Input: [[2,4]]
Expected: 4
Input: [[3,3,3,3]]
Expected: 12
Constraints
- 1 <= heights.length <= 10^5
- 0 <= heights[i] <= 10^4
Recruiter Fast-Track ReferralVerified Candidate
Direct pipeline to Google, Amazon, Microsoft, Swiggy, & Uber recruiters
Top DevScore profiles bypass resume screening filters. Every verified problem solve writes authentic proof-of-work to your profile and dispatches you directly into employer inboxes on RoleNest.
Explore 5,000+ Direct ATS Openings on RoleNest ↗✓ Direct Referral Active
Language:
Ready to test. Click Run Code or Submit Solution to run test cases in isolated browser sandbox.