1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-09 01:11:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个下标从 <strong>0</strong>&nbsp;开始,大小为&nbsp;<code>m x n</code>&nbsp;的二进制矩阵&nbsp;<code>land</code>&nbsp;,其中 <code>0</code>&nbsp;表示一单位的森林土地,<code>1</code>&nbsp;表示一单位的农场土地。</p>\n\n<p>为了让农场保持有序,农场土地之间以矩形的 <strong>农场组</strong> 的形式存在。每一个农场组都 <strong>仅</strong>&nbsp;包含农场土地。且题目保证不会有两个农场组相邻,也就是说一个农场组中的任何一块土地都 <strong>不会</strong>&nbsp;与另一个农场组的任何一块土地在四个方向上相邻。</p>\n\n<p><code>land</code>&nbsp;可以用坐标系统表示,其中 <code>land</code>&nbsp;左上角坐标为&nbsp;<code>(0, 0)</code>&nbsp;,右下角坐标为&nbsp;<code>(m-1, n-1)</code>&nbsp;。请你找到所有 <b>农场组</b>&nbsp;最左上角和最右下角的坐标。一个左上角坐标为&nbsp;<code>(r<sub>1</sub>, c<sub>1</sub>)</code>&nbsp;且右下角坐标为&nbsp;<code>(r<sub>2</sub>, c<sub>2</sub>)</code>&nbsp;的 <strong>农场组</strong> 用长度为 4 的数组&nbsp;<code>[r<sub>1</sub>, c<sub>1</sub>, r<sub>2</sub>, c<sub>2</sub>]</code>&nbsp;表示。</p>\n\n<p>请你返回一个二维数组,它包含若干个长度为 4 的子数组,每个子数组表示 <code>land</code>&nbsp;中的一个 <strong>农场组</strong>&nbsp;。如果没有任何农场组,请你返回一个空数组。可以以 <strong>任意顺序</strong>&nbsp;返回所有农场组。</p>\n\n<p><strong>示例 1</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/07/27/screenshot-2021-07-27-at-12-23-15-copy-of-diagram-drawio-diagrams-net.png\" style=\"width: 300px; height: 300px;\"></p>\n\n<pre><b>输入:</b>land = [[1,0,0],[0,1,1],[0,1,1]]\n<b>输出:</b>[[0,0,0,0],[1,1,2,2]]\n<strong>解释:</strong>\n第一个农场组的左上角为 land[0][0] ,右下角为 land[0][0] 。\n第二个农场组的左上角为 land[1][1] ,右下角为 land[2][2] 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/07/27/screenshot-2021-07-27-at-12-30-26-copy-of-diagram-drawio-diagrams-net.png\" style=\"width: 200px; height: 200px;\"></p>\n\n<pre><b>输入:</b>land = [[1,1],[1,1]]\n<b>输出:</b>[[0,0,1,1]]\n<strong>解释:</strong>\n第一个农场组左上角为 land[0][0] ,右下角为 land[1][1] 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/07/27/screenshot-2021-07-27-at-12-32-24-copy-of-diagram-drawio-diagrams-net.png\" style=\"width: 100px; height: 100px;\"></p>\n\n<pre><b>输入:</b>land = [[0]]\n<b>输出:</b>[]\n<b>解释:</b>\n没有任何农场组。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>m == land.length</code></li>\n\t<li><code>n == land[i].length</code></li>\n\t<li><code>1 &lt;= m, n &lt;= 300</code></li>\n\t<li><code>land</code>&nbsp;只包含&nbsp;<code>0</code>&nbsp;和&nbsp;<code>1</code>&nbsp;。</li>\n\t<li>农场组都是 <strong>矩形</strong>&nbsp;的形状。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 6,
"likes": 8,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"4K\", \"totalSubmission\": \"6.7K\", \"totalAcceptedRaw\": 4003, \"totalSubmissionRaw\": 6725, \"acRate\": \"59.5%\"}",
"stats": "{\"totalAccepted\": \"4.1K\", \"totalSubmission\": \"6.9K\", \"totalAcceptedRaw\": 4129, \"totalSubmissionRaw\": 6930, \"acRate\": \"59.6%\"}",
"hints": [
"Since every group of farmland is rectangular, the top left corner of each group will have the smallest x-coordinate and y-coordinate of any farmland in the group.",
"Similarly, the bootm right corner of each group will have the largest x-coordinate and y-coordinate of any farmland in the group.",