Description
Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.
Example:
| |
在给出的矩阵中,1表示元素,0表示空,找出最大矩形的面积。
Solution
本题可以利用《84. Largest Rectangle in Histogram》
的代码。
下面来看看如何转换成 84 题的直方图求解问题:
| |
下面largestRectangleArea的代码点击这里查看。
| |