You are viewing a single comment's thread. Return to all comments →
Python
def largestRectangle(h): if not len(h) > 0: return 0 areaMax = 0 for i in range(len(h)): ht = h[i] le = i ri = i while(0 < le and h[le - 1] >= ht): le = le - 1 while(ri < len(h) and h[ri] >= ht): ri = ri + 1 areaMax = max(areaMax, ht * (ri - le)) return areaMax
Seems like cookies are disabled on this browser, please enable them to open this website
Largest Rectangle
You are viewing a single comment's thread. Return to all comments →
Python