You are viewing a single comment's thread. Return to all comments →
Same as LeetCodes "Largest Rectangle in Histogram" https://leetcode.com/problems/largest-rectangle-in-histogram/submissions/1092315461/
stack = [-1] h.append(0) maxA = 0 for i in range(len(h)): while h[i] < h[stack[-1]]: height = h[stack.pop()] width = i - stack[-1] -1 if height * width > maxA: maxA = height * width stack.append(i) return maxA
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 →
Same as LeetCodes "Largest Rectangle in Histogram" https://leetcode.com/problems/largest-rectangle-in-histogram/submissions/1092315461/