"A collection of essential coding algorithms and popular code solutions. Optimized for interviews and competitive programming, covering a wide range of topics from sorting to dynamic programming.”
26
stars
277
forks
source link
Implement Finding Maximum area in a Histogram #298
Write a Java program to compute the maximum rectangular area in a histogram. Given an array where each element represents the height of bars in a histogram, the program should determine the largest possible rectangular area that can be formed using consecutive bars.
Description:
Write a Java program to compute the maximum rectangular area in a histogram. Given an array where each element represents the height of bars in a histogram, the program should determine the largest possible rectangular area that can be formed using consecutive bars.
Test Cases:
Input: histogram = [6, 2, 5, 4, 5, 1, 6] Expected Output: 12
Input: histogram = [2, 1, 5, 6, 2, 3] Expected Output: 10
Constraints:
Histogram heights are non-negative integers
Image taken from GFG