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 (English)/最大黑方阵(English) [max-black-square-lcci].html

35 lines
1.4 KiB
HTML

<p>Imagine you have a square matrix, where each cell (pixel) is either black or white Design an algorithm to find the maximum subsquare such that all four borders are filled with black pixels.</p>
<p>Return an array&nbsp;<code>[r, c, size]</code>, where&nbsp;<code>r</code>,&nbsp;<code>c</code>&nbsp;are the row number and the column number of the subsquare&#39;s upper left corner respectively, and <code>size</code>&nbsp;is the side length of the subsquare. If there are more than one answers, return the one that has smallest <code>r</code>. If there are more than one answers that have the same <code>r</code>, return the one that has smallest <code>c</code>. If there&#39;s no answer, return an empty array.</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:
</strong>[
&nbsp; [1,0,1],
&nbsp; [<strong>0,0</strong>,1],
&nbsp; [<strong>0,0</strong>,1]
]
<strong>Output: </strong>[1,0,2]
<strong>Explanation:</strong> 0 represents black, and 1 represents white, bold elements in the input is the answer.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:
</strong>[
&nbsp; [<strong>0</strong>,1,1],
&nbsp; [1,0,1],
&nbsp; [1,1,0]
]
<strong>Output: </strong>[0,0,1]
</pre>
<p><strong>Note: </strong></p>
<ul>
<li><code>matrix.length == matrix[0].length &lt;= 200</code></li>
</ul>