Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Speedy category for Largest Rectangle in a Histogram by yoichi
def largest_histogram(rects):
s = 0
for i in range(len(rects)):
for j in reversed(range(rects[i])):
if i > 0 and rects[i-1] > j+1:
break
for k in range(i, len(rects)):
if k == len(rects)-1 or rects[k+1] < j+1:
s = max(s, (k-i+1) * (j+1))
break
return s
March 29, 2017