1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/重新排列后的最大子矩阵 [largest-submatrix-with-rearrangements].html
2022-03-29 12:43:11 +08:00

53 lines
1.9 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个二进制矩阵 <code>matrix</code> ,它的大小为 <code>m x n</code> ,你可以将 <code>matrix</code> 中的 <strong></strong> 按任意顺序重新排列。</p>
<p>请你返回最优方案下将 <code>matrix</code> 重新排列后,全是 <code>1</code> 的子矩阵面积。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/01/17/screenshot-2020-12-30-at-40536-pm.png" style="width: 300px; height: 144px;" /></strong></p>
<pre>
<b>输入:</b>matrix = [[0,0,1],[1,1,1],[1,0,1]]
<b>输出:</b>4
<b>解释:</b>你可以按照上图方式重新排列矩阵的每一列。
最大的全 1 子矩阵是上图中加粗的部分,面积为 4 。
</pre>
<p><strong>示例 2</strong></p>
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/01/17/screenshot-2020-12-30-at-40852-pm.png" style="width: 500px; height: 62px;" /></p>
<pre>
<b>输入:</b>matrix = [[1,0,1,0,1]]
<b>输出:</b>3
<b>解释:</b>你可以按照上图方式重新排列矩阵的每一列。
最大的全 1 子矩阵是上图中加粗的部分,面积为 3 。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<b>输入:</b>matrix = [[1,1,0],[1,0,1]]
<b>输出:</b>2
<b>解释:</b>由于你只能整列整列重新排布,所以没有比面积为 2 更大的全 1 子矩形。</pre>
<p><strong>示例 4</strong></p>
<pre>
<b>输入:</b>matrix = [[0,0],[0,0]]
<b>输出:</b>0
<b>解释:</b>由于矩阵中没有 1 ,没有任何全 1 的子矩阵,所以面积为 0 。</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == matrix.length</code></li>
<li><code>n == matrix[i].length</code></li>
<li><code>1 <= m * n <= 10<sup>5</sup></code></li>
<li><code>matrix[i][j]</code> 要么是 <code>0</code> ,要么是 <code>1</code></li>
</ul>