码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] 827. Making A Large Island 建造一个巨大岛屿

时间:2019-10-14 01:24:21      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:note   output   tput   ems   www   The   github   direct   hub   



In a 2D grid of?0s and?1s, we change at most one?0?to a?1.

After, what is the size of the largest island??(An island is a 4-directionally connected group of?1s).

Example 1:

Input: [[1, 0], [0, 1]]
Output: 3
Explanation: Change one 0 to 1 and connect two 1s, then we get an island with area = 3.

Example 2:

Input: [[1, 1], [1, 0]]
Output: 4
Explanation: Change the 0 to 1 and make the island bigger, only one island with area = 4.

Example 3:

Input: [[1, 1], [1, 1]]
Output: 4
Explanation: Can't change any 0 to 1, only one island with area = 4.

Notes:

  • 1 <= grid.length = grid[0].length <= 50.
  • 0 <= grid[i][j] <= 1.



Github 同步地址:

https://github.com/grandyang/leetcode/issues/827



参考资料:

https://leetcode.com/problems/making-a-large-island/



LeetCode All in One 题目讲解汇总(持续更新中...)

[LeetCode] 827. Making A Large Island 建造一个巨大岛屿

标签:note   output   tput   ems   www   The   github   direct   hub   

原文地址:https://www.cnblogs.com/grandyang/p/11669063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!