1 解题思想
这道题我是转化成上一道题来做的,对于每一行,看成给一个直方图
在每一行上,首先按照直方图的方式进行统计,然后记录并更新最大,因此计算请看:
Leetcode 84. Largest Rectangle in Histogram 最大矩形 解题报告
2 原题
Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.
Subscribe to see which companies asked this question
3 AC解
public class Solution {
public int largestRectangleArea(int[] heights) {
Stack<Integer> stack = new Stack<Integer>();
int<