[Leetcode] 827. MAKING A Large Island built a huge island

In a 2D grid of?0s and?1s, we change at most one?0< /code>?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.< /pre>

Notes:

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

Github synchronization address:

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

Reference materials:

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

LeetCode All in One topic explanation summary (continuous update...)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2503 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.