1568. Minimum Number of Days to Disconnect Island
Previous1567. Maximum Length of Subarray With Positive ProductNext1569. Number of Ways to Reorder Array to Get Same BST
Last updated
Last updated
https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island
Given a 2D grid
consisting of 1
s (land) and 0
s (water). An island is a maximal 4-directionally (horizontal or vertical) connected group of 1
s.
The grid is said to be connected if we have exactly one island, otherwise is said disconnected.
In one day, we are allowed to change any single land cell (1)
into a water cell (0)
.
Return the minimum number of days to disconnect the grid.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= grid.length, grid[i].length <= 30
grid[i][j]
is 0
or 1
.