Back to course home
0% completed
Solution: Minimum Number of Days to Disconnect Island
Problem Statement
You are given a binary grid of size m x n
, where each cell can either be land (marked as 1
) or water (marked as 0
). An island is a group of connected land cells (1
s) that are adjacent either horizontally or vertically.
The grid is considered connected if it contains exactly one island.
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.
Examples
Example 1:
- Input: grid =
[[1, 1, 0], [1, 1, 0], [0, 1, 1]]
.....
.....
.....
Like the course? Get enrolled and start learning!