Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
O(N) solution in Speedy category for Largest Rectangle in a Histogram by David_Jones
def largest_histogram(histogram):
histogram = [-1] + histogram + [-1]
max_area = 0
stack = [0]
for i in range(len(histogram)):
while histogram[i] < histogram[stack[-1]]:
max_area = max(max_area,
histogram[stack.pop()] * (i - stack[-1] - 1))
stack.append(i)
return max_area
May 12, 2019