You are viewing a single comment's thread. Return to all comments →
def largestRectangle3(h):
area = float("-inf") numOfBuildings = 0 minHeight = float("inf") for i in range(len(h)): numOfBuildings += 1 minHeight = min(minHeight, h[i]) for j in range(i-1, -1,-1): if h[j] >= minHeight: numOfBuildings += 1 else: break for j in range(i+1, len(h)): if h[j] >= minHeight: numOfBuildings += 1 else: break area = max(area, (numOfBuildings * minHeight)) numOfBuildings = 0 minHeight = float("inf") return area
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 →
def largestRectangle3(h):