mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
35 lines
1.4 KiB
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 <code>[r, c, size]</code>, where <code>r</code>, <code>c</code> are the row number and the column number of the subsquare's upper left corner respectively, and <code>size</code> 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's no answer, return an empty array.</p>
|
|
|
|
|
|
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input:
|
|
|
|
</strong>[
|
|
|
|
[1,0,1],
|
|
|
|
[<strong>0,0</strong>,1],
|
|
|
|
[<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>[
|
|
|
|
[<strong>0</strong>,1,1],
|
|
|
|
[1,0,1],
|
|
|
|
[1,1,0]
|
|
|
|
]
|
|
|
|
<strong>Output: </strong>[0,0,1]
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<p><strong>Note: </strong></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><code>matrix.length == matrix[0].length <= 200</code></li>
|
|
|
|
</ul>
|
|
|