Skip to content

Commit 6dcab15

Browse files
committed
Create README - LeetHub
1 parent 0dcf4d4 commit 6dcab15

File tree

1 file changed

+35
-0
lines changed
  • 1568-minimum-number-of-days-to-disconnect-island

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island/">1568. Minimum Number of Days to Disconnect Island</a></h2><h3>Hard</h3><hr><div><p>You are given an <code>m x n</code> binary grid <code>grid</code> where <code>1</code> represents land and <code>0</code> represents water. An <strong>island</strong> is a maximal <strong>4-directionally</strong> (horizontal or vertical) connected group of <code>1</code>'s.</p>
2+
3+
<p>The grid is said to be <strong>connected</strong> if we have <strong>exactly one island</strong>, otherwise is said <strong>disconnected</strong>.</p>
4+
5+
<p>In one day, we are allowed to change <strong>any </strong>single land cell <code>(1)</code> into a water cell <code>(0)</code>.</p>
6+
7+
<p>Return <em>the minimum number of days to disconnect the grid</em>.</p>
8+
9+
<p>&nbsp;</p>
10+
<p><strong class="example">Example 1:</strong></p>
11+
<img alt="" src="https://assets.leetcode.com/uploads/2021/12/24/land1.jpg" style="width: 500px; height: 169px;">
12+
<pre><strong>Input:</strong> grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]
13+
14+
<strong>Output:</strong> 2
15+
<strong>Explanation:</strong> We need at least 2 days to get a disconnected grid.
16+
Change land grid[1][1] and grid[0][2] to water and get 2 disconnected island.
17+
</pre>
18+
19+
<p><strong class="example">Example 2:</strong></p>
20+
<img alt="" src="https://assets.leetcode.com/uploads/2021/12/24/land2.jpg" style="width: 404px; height: 85px;">
21+
<pre><strong>Input:</strong> grid = [[1,1]]
22+
<strong>Output:</strong> 2
23+
<strong>Explanation:</strong> Grid of full water is also disconnected ([[1,1]] -&gt; [[0,0]]), 0 islands.
24+
</pre>
25+
26+
<p>&nbsp;</p>
27+
<p><strong>Constraints:</strong></p>
28+
29+
<ul>
30+
<li><code>m == grid.length</code></li>
31+
<li><code>n == grid[i].length</code></li>
32+
<li><code>1 &lt;= m, n &lt;= 30</code></li>
33+
<li><code>grid[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
34+
</ul>
35+
</div>

0 commit comments

Comments
 (0)