Class Solution
java.lang.Object
g0001_0100.s0085_maximal_rectangle.Solution
85 - Maximal Rectangle.<p>Hard</p>
<p>Given a <code>rows x cols</code> binary <code>matrix</code> filled with <code>0</code>’s and <code>1</code>’s, find the largest rectangle containing only <code>1</code>’s and return <em>its area</em>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/09/14/maximal.jpg" alt="" /></p>
<p><strong>Input:</strong> matrix = [[“1”,“0”,“1”,“0”,“0”],[“1”,“0”,“1”,“1”,“1”],[“1”,“1”,“1”,“1”,“1”],[“1”,“0”,“0”,“1”,“0”]]</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> The maximal rectangle is shown in the above picture.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> matrix = []</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> matrix = [[“0”]]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Example 4:</strong></p>
<p><strong>Input:</strong> matrix = [[“1”]]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Example 5:</strong></p>
<p><strong>Input:</strong> matrix = [[“0”,“0”]]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>rows == matrix.length</code></li>
<li><code>cols == matrix[i].length</code></li>
<li><code>0 <= row, cols <= 200</code></li>
<li><code>matrix[i][j]</code> is <code>'0'</code> or <code>'1'</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
maximalRectangle
public int maximalRectangle(char[][] matrix)
-