You are viewing a single comment's thread. Return to all comments →
Python, recursive, not O(N) but short.
def largestRectangle(h): if h: i = min(range(len(h)), key=h.__getitem__) return max(h[i] * len(h), largestRectangle(h[:i]), largestRectangle(h[i+1:])) return 0
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, recursive, not O(N) but short.