How can I find the maximum distance from land in LeetCode 1162 problem?

2026-05-29 13:562阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计408个文字,预计阅读时间需要2分钟。

How can I find the maximum distance from land in LeetCode 1162 problem?

题目链接:1162. As Far from Land as Possible题目大意:给你一个01矩阵,只能上下左右走,每个0需要找到离自己最近的1,求这些最近距离中的最大值。题目思路:使用BFS(广度优先搜索)进行搜索,记录每个0到最近的1的距离,最后找出最大值。

阅读全文

本文共计408个文字,预计阅读时间需要2分钟。

How can I find the maximum distance from land in LeetCode 1162 problem?

题目链接:1162. As Far from Land as Possible题目大意:给你一个01矩阵,只能上下左右走,每个0需要找到离自己最近的1,求这些最近距离中的最大值。题目思路:使用BFS(广度优先搜索)进行搜索,记录每个0到最近的1的距离,最后找出最大值。

阅读全文