mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<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> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
<img alt="" src="https://assets.leetcode.com/uploads/2020/09/14/maximal.jpg" style="width: 402px; height: 322px;" />
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
 | 
						|
<strong>Output:</strong> 6
 | 
						|
<strong>Explanation:</strong> The maximal rectangle is shown in the above picture.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> matrix = [["0"]]
 | 
						|
<strong>Output:</strong> 0
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 3:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> matrix = [["1"]]
 | 
						|
<strong>Output:</strong> 1
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>rows == matrix.length</code></li>
 | 
						|
	<li><code>cols == matrix[i].length</code></li>
 | 
						|
	<li><code>1 <= row, cols <= 200</code></li>
 | 
						|
	<li><code>matrix[i][j]</code> is <code>'0'</code> or <code>'1'</code>.</li>
 | 
						|
</ul>
 |