PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Palo

Find Maximum Rectangle in Bar Chart

Last updated: May 5, 2026

Quick Overview

This question evaluates algorithmic problem-solving and data structure proficiency in computing the maximum rectangular area within a histogram-like array, focusing on contiguous segment analysis and range-based aggregation.

  • medium
  • Palo
  • Coding & Algorithms
  • Software Engineer

Find Maximum Rectangle in Bar Chart

Company: Palo

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given an array `heights` of `n` non-negative integers, where each value represents the height of a vertical bar in a bar chart and every bar has width `1`, find the maximum possible rectangular area that can be formed by choosing one or more consecutive bars. A rectangle spanning bars `i` through `j` has height equal to the minimum height among those bars and width `j - i + 1`. Return the maximum area. **Example 1:** ```text Input: heights = [2, 1, 5, 6, 2, 3] Output: 10 Explanation: The best rectangle spans the bars with heights 5 and 6, giving area 5 * 2 = 10. ``` **Example 2:** ```text Input: heights = [2, 4] Output: 4 ``` **Constraints:** - `1 <= n <= 100000` - `0 <= heights[i] <= 1000000000` - The answer fits in a 64-bit signed integer.

Quick Answer: This question evaluates algorithmic problem-solving and data structure proficiency in computing the maximum rectangular area within a histogram-like array, focusing on contiguous segment analysis and range-based aggregation.

Related Interview Questions

  • Find minimum tanks to cover all houses - Palo (medium)
  • Implement three whiteboard coding tasks - Palo (easy)
Palo logo
Palo
Feb 20, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0

Given an array heights of n non-negative integers, where each value represents the height of a vertical bar in a bar chart and every bar has width 1, find the maximum possible rectangular area that can be formed by choosing one or more consecutive bars.

A rectangle spanning bars i through j has height equal to the minimum height among those bars and width j - i + 1.

Return the maximum area.

Example 1:

Input: heights = [2, 1, 5, 6, 2, 3]
Output: 10
Explanation: The best rectangle spans the bars with heights 5 and 6, giving area 5 * 2 = 10.

Example 2:

Input: heights = [2, 4]
Output: 4

Constraints:

  • 1 <= n <= 100000
  • 0 <= heights[i] <= 1000000000
  • The answer fits in a 64-bit signed integer.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Palo•More Software Engineer•Palo Software Engineer•Palo Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.