###### [LeetCode]84. Largest Rectangle in Histogram

https://leetcode.com/problems/largest-rectangle-in-histogram/

public class Solution {
public int largestRectangleArea(int[] heights) {
// 始终保持升序序列
Stack<Integer> stack = new Stack();
int res = 0;
for (int i = 0; i <= heights.length; i++) {
int height = i == heights.length ? 0 : heights[i];
while (!stack.isEmpty() && height <= heights[stack.peek()]) {
int h = heights[stack.pop()];
int j = stack.isEmpty() ? -1 : stack.peek();
res = Math.max(res, h * (i - j - 1));
}
stack.push(i);
}
return res;
}
}

#### LeetCode --- 84. Largest Rectangle in Histogram

2015-04-03 17:07:41

#### LeetCode（84） Largest Rectangle in Histogram

2015-12-21 15:34:05

#### [leetcode-84]Largest Rectangle in Histogram(c++)

2015-08-09 17:29:31

#### LeetCode84 Largest Rectangle in Histogram java题解

2015-06-27 11:21:16

#### LeetCode Largest Rectangle in Histogram （单调栈）

2015-04-11 21:37:03

#### LeetCode84——Largest Rectangle in Histogram

2016-01-27 22:34:22

#### [leetcode] 84. Largest Rectangle in Histogram 解题报告

2015-12-17 03:50:01

#### leetcode_question_85 Largest Rectangle in Histogram

2013-09-18 14:00:28

#### LeetCode 84 Largest Rectangle in Histogram (Python详解及实现)

2017-08-09 15:34:40

#### LeetCode Largest Rectangle in Histogram

2015年06月22日 2.67MB 下载

## 不良信息举报

[LeetCode]84. Largest Rectangle in Histogram