We use cookies to provide you with an optimal experience and relevant communication.Cookie Policy
Back to course home
0% completed
Minimum Number of Days to Disconnect Island (hard)
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!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible