mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-25 23:08:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你两个 <code>m x n</code> 的二进制矩阵 <code>grid1</code> 和 <code>grid2</code> ,它们只包含 <code>0</code> (表示水域)和 <code>1</code> (表示陆地)。一个 <strong>岛屿</strong> 是由 <strong>四个方向</strong> (水平或者竖直)上相邻的 <code>1</code> 组成的区域。任何矩阵以外的区域都视为水域。</p>\n\n<p>如果 <code>grid2</code> 的一个岛屿,被 <code>grid1</code> 的一个岛屿 <strong>完全</strong> 包含,也就是说 <code>grid2</code> 中该岛屿的每一个格子都被 <code>grid1</code> 中同一个岛屿完全包含,那么我们称 <code>grid2</code> 中的这个岛屿为 <strong>子岛屿</strong> 。</p>\n\n<p>请你返回 <code>grid2</code> 中 <strong>子岛屿</strong> 的 <strong>数目</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/06/10/test1.png\" style=\"width: 493px; height: 205px;\">\n<pre><b>输入:</b>grid1 = [[1,1,1,0,0],[0,1,1,1,1],[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1]], grid2 = [[1,1,1,0,0],[0,0,1,1,1],[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0]]\n<b>输出:</b>3\n<strong>解释:</strong>如上图所示,左边为 grid1 ,右边为 grid2 。\ngrid2 中标红的 1 区域是子岛屿,总共有 3 个子岛屿。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/06/03/testcasex2.png\" style=\"width: 491px; height: 201px;\">\n<pre><b>输入:</b>grid1 = [[1,0,1,0,1],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[1,0,1,0,1]], grid2 = [[0,0,0,0,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0],[1,0,0,0,1]]\n<b>输出:</b>2 \n<strong>解释:</strong>如上图所示,左边为 grid1 ,右边为 grid2 。\ngrid2 中标红的 1 区域是子岛屿,总共有 2 个子岛屿。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>m == grid1.length == grid2.length</code></li>\n\t<li><code>n == grid1[i].length == grid2[i].length</code></li>\n\t<li><code>1 <= m, n <= 500</code></li>\n\t<li><code>grid1[i][j]</code> 和 <code>grid2[i][j]</code> 都要么是 <code>0</code> 要么是 <code>1</code> 。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 41,
|
||||
"likes": 47,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"10.3K\", \"totalSubmission\": \"16.2K\", \"totalAcceptedRaw\": 10329, \"totalSubmissionRaw\": 16245, \"acRate\": \"63.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"11.9K\", \"totalSubmission\": \"18.5K\", \"totalAcceptedRaw\": 11923, \"totalSubmissionRaw\": 18543, \"acRate\": \"64.3%\"}",
|
||||
"hints": [
|
||||
"Let's use floodfill to iterate over the islands of the second grid",
|
||||
"Let's note that if all the cells in an island in the second grid if they are represented by land in the first grid then they are connected hence making that island a sub-island"
|
||||
|
||||
Reference in New Issue
Block a user