Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Largest Rectangle in a Histogram by fed.kz
def largest_histogram(histogram):
height = 1
area = 0
while any(histogram):
max_count = 0
count = 0
for key in histogram:
if key == 0:
max_count = max(count,max_count)
count = 0
else:
count += 1
max_count = max(count, max_count)
area = max(area, max_count * height)
histogram = [max(key - 1, 0) for key in histogram]
height += 1
return area
Nov. 6, 2018