Problem :
Given an array of non-negative integers. Construct a histogram using array indices as height.
Assume the width as 1 unit. Find the rectangle with maximum area. Try to come up with an optimal solution.
Solution :
This problem can be solved in O(n) time, by comparing the prev and the current elements.
Here is the solution for the same.
Given an array of non-negative integers. Construct a histogram using array indices as height.
Assume the width as 1 unit. Find the rectangle with maximum area. Try to come up with an optimal solution.
Solution :
This problem can be solved in O(n) time, by comparing the prev and the current elements.
Here is the solution for the same.
No comments:
Post a Comment