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 (Chinese)/最大人工岛 [making-a-large-island].html
2022-03-29 12:43:11 +08:00

41 lines
1.2 KiB
HTML
Raw Permalink 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>n x n</code> 二进制矩阵 <code>grid</code><strong>最多</strong> 只能将一格 <code>0</code> 变成 <code>1</code></p>
<p>返回执行此操作后,<code>grid</code> 中最大的岛屿面积是多少?</p>
<p><strong>岛屿</strong> 由一组上、下、左、右四个方向相连的 <code>1</code> 形成。</p>
<p> </p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入: </strong>grid = [[1, 0], [0, 1]]
<strong>输出:</strong> 3
<strong>解释:</strong> 将一格0变成1最终连通两个小岛得到面积为 3 的岛屿。
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入: </strong>grid =<strong> </strong>[[1, 1], [1, 0]]
<strong>输出:</strong> 4
<strong>解释:</strong> 将一格0变成1岛屿的面积扩大为 4。</pre>
<p><strong>示例 3:</strong></p>
<pre>
<strong>输入: </strong>grid = [[1, 1], [1, 1]]
<strong>输出:</strong> 4
<strong>解释:</strong> 没有0可以让我们变成1面积依然为 4。</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>1 <= n <= 500</code></li>
<li><code>grid[i][j]</code><code>0</code><code>1</code></li>
</ul>