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)/最大黑方阵 [max-black-square-lcci].html
2022-03-29 12:43:11 +08:00

33 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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>给定一个方阵,其中每个单元(像素)非黑即白。设计一个算法,找出 4 条边皆为黑色像素的最大子方阵。</p>
<p>返回一个数组 <code>[r, c, size]</code> ,其中&nbsp;<code>r</code>,&nbsp;<code>c</code>&nbsp;分别代表子方阵左上角的行号和列号,<code>size</code> 是子方阵的边长。若有多个满足条件的子方阵,返回 <code>r</code> 最小的,若 <code>r</code> 相同,返回 <code>c</code> 最小的子方阵。若无满足条件的子方阵,返回空数组。</p>
<p><strong>示例 1:</strong></p>
<pre><strong>输入:
</strong>[
&nbsp; [1,0,1],
&nbsp; [<strong>0,0</strong>,1],
&nbsp; [<strong>0,0</strong>,1]
]
<strong>输出: </strong>[1,0,2]
<strong>解释: </strong>输入中 0 代表黑色1 代表白色,标粗的元素即为满足条件的最大子方阵
</pre>
<p><strong>示例 2:</strong></p>
<pre><strong>输入:
</strong>[
&nbsp; [<strong>0</strong>,1,1],
&nbsp; [1,0,1],
&nbsp; [1,1,0]
]
<strong>输出: </strong>[0,0,1]
</pre>
<p><strong>提示:</strong></p>
<ul>
<li><code>matrix.length == matrix[0].length &lt;= 200</code></li>
</ul>