给定一个仅包含 0
和 1
、大小为 rows x cols
的二维二进制矩阵,找出只包含 1
的最大矩形,并返回其面积。
示例:
1 | 输入:matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] |
分析:
1 | 1、枚举矩形的边界,从边界出发统计连续1的个数,之后转化为求柱状图中的最大矩形 |
代码
1 | class Solution { |
[原题链接](85. 最大矩形 - 力扣(Leetcode))
[相似题目](84. 柱状图中最大的矩形 - 力扣(Leetcode))