mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
add leetcode problem-cn part3
This commit is contained in:
36
算法题(国内版)/problem (Chinese)/最短的桥 [shortest-bridge].html
Normal file
36
算法题(国内版)/problem (Chinese)/最短的桥 [shortest-bridge].html
Normal file
@@ -0,0 +1,36 @@
|
||||
<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>
|
Reference in New Issue
Block a user