• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
January 10, 2024 |110 Views
SDE Sheet - Largest Rectangular Area in a Histogram
  Share   Like
Description
Discussion

This is part of Stack and Queue section under GFG SDE Sheet

In this problem, we have to find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars have the same width and the width is 1 unit, there will be N bars height of each bar will be given by the array arr.

Example :

Input:
N = 7
arr[] = {6,2,5,4,5,1,6}
Output: 12

Explanation: In this example the largest area would be 12 of height 4 and width 3. We can achieve this 
area by choosing 3rd, 4th and 5th bars

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/largest-rectangular-area-in-a-histogram-using-segment-tree/
Problem: https://www.geeksforgeeks.org/problems/maximum-rectangular-area-in-a-histogram-1587115620/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More