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

37 lines
1019 B
HTML
Raw Normal View History

2022-03-27 20:46:41 +08:00
<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>