1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最短的桥 [shortest-bridge].html
2022-03-29 12:43:11 +08:00

37 lines
1019 B
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>A</code> 中,存在两座岛。(岛是由四面相连的 <code>1</code> 形成的一个最大组。)</p>
<p>现在,我们可以将 <code>0</code> 变为 <code>1</code>,以使两座岛连接起来,变成一座岛。</p>
<p>返回必须翻转的 <code>0</code> 的最小数目。(可以保证答案至少是 <code>1</code> 。)</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>A = [[0,1],[1,0]]
<strong>输出:</strong>1
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>A = [[0,1,0],[0,0,0],[0,0,1]]
<strong>输出:</strong>2
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>A = [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]
<strong>输出:</strong>1</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 <= A.length == A[0].length <= 100</code></li>
<li><code>A[i][j] == 0</code><code>A[i][j] == 1</code></li>
</ul>