力扣最大面积最大矩形给定一个由0和1填充的二维二进制矩阵,找到仅包含1的最大矩形并返回其面积。

Example:

Input:

[

[\"1\",\"0\",\"0\"],

[\"1\",\"0\",\"1\"],

[\"1\",\"1\"],

[\"1\",\"0\",\"1\",\"0\"]

]

Output: 6

执行:


class Solution {

 public int largestRectangleArea(int[] heights) {

 Stack<integer> stack = new Stack<>();

 int maxArea = 0;

 int index = 0;

 while (index < heights.length) {

 if (stack.empty() || heights[index] >= heights[stack.peek()]) {

 stack.push(index++);

 } else {

 int top = stack.pop();

 int width = ...

</integer>