1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 15:31:43 +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>你现在手里有一份大小为<meta charset=\"UTF-8\" />&nbsp;<code>n x n</code>&nbsp;的 网格 <code>grid</code>,上面的每个 单元格 都用&nbsp;<code>0</code>&nbsp;和&nbsp;<code>1</code>&nbsp;标记好了。其中&nbsp;<code>0</code>&nbsp;代表海洋,<code>1</code>&nbsp;代表陆地。</p>\n\n<p>请你找出一个海洋单元格,这个海洋单元格到离它最近的陆地单元格的距离是最大的,并返回该距离。如果网格上只有陆地或者海洋,请返回&nbsp;<code>-1</code>。</p>\n\n<p>我们这里说的距离是「曼哈顿距离」(&nbsp;Manhattan Distance<code>(x0, y0)</code> 和&nbsp;<code>(x1, y1)</code>&nbsp;这两个单元格之间的距离是&nbsp;<code>|x0 - x1| + |y0 - y1|</code>&nbsp;。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/08/17/1336_ex1.jpeg\" /></strong></p>\n\n<pre>\n<strong>输入:</strong>grid = [[1,0,1],[0,0,0],[1,0,1]]\n<strong>输出:</strong>2\n<strong>解释: </strong>\n海洋单元格 (1, 1) 和所有陆地单元格之间的距离都达到最大,最大距离为 2。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/08/17/1336_ex2.jpeg\" /></strong></p>\n\n<pre>\n<strong>输入:</strong>grid = [[1,0,0],[0,0,0],[0,0,0]]\n<strong>输出:</strong>4\n<strong>解释: </strong>\n海洋单元格 (2, 2) 和所有陆地单元格之间的距离都达到最大,最大距离为 4。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<p><meta charset=\"UTF-8\" /></p>\n\n<ul>\n\t<li><code>n == grid.length</code></li>\n\t<li><code>n == grid[i].length</code></li>\n\t<li><code>1 &lt;= n&nbsp;&lt;= 100</code></li>\n\t<li><code>grid[i][j]</code>&nbsp;不是&nbsp;<code>0</code>&nbsp;就是&nbsp;<code>1</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 257,
"likes": 265,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Shortest Distance from All Buildings\", \"titleSlug\": \"shortest-distance-from-all-buildings\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u79bb\\u5efa\\u7b51\\u7269\\u6700\\u8fd1\\u7684\\u8ddd\\u79bb\"}]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"42.8K\", \"totalSubmission\": \"90.8K\", \"totalAcceptedRaw\": 42822, \"totalSubmissionRaw\": 90781, \"acRate\": \"47.2%\"}",
"stats": "{\"totalAccepted\": \"43.8K\", \"totalSubmission\": \"92.9K\", \"totalAcceptedRaw\": 43764, \"totalSubmissionRaw\": 92941, \"acRate\": \"47.1%\"}",
"hints": [
"Can you think of this problem in a backwards way ?",
"Imagine expanding outward from each land cell. What kind of search does that ?",