question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
word-ladder-ii
25 ms | Use less memory than 97% | BFS + DFS | Golang |
25-ms-use-less-memory-than-97-bfs-dfs-go-o53f
Let consider each string in wordList as a vertex on a graph, and if two strings differ by at most one character, we will connect an edge with weight 1 between t
mbfibat
NORMAL
2022-08-14T08:40:53.377936+00:00
2022-08-14T08:42:05.353066+00:00
474
false
- Let consider each string in ```wordList``` as a vertex on a graph, and if two strings differ by at most one character, we will connect an edge with weight ```1``` between them. The problem become: "Find the shortest path, single source, single destination, on a graph where each edge\'s weight is equal to 1".\n\n- The...
5
0
['Depth-First Search', 'Binary Search Tree', 'Go']
0
word-ladder-ii
C++ | Floyd-Warshall + BFS | O(n^3) | explanation
c-floyd-warshall-bfs-on3-explanation-by-kbcyg
\nclass Solution {\npublic:\n vector <int> isc[501];\n long dis[501][501];\n int n,tar,as;\n bool jc(string x,string y){\n int v=0;\n
SunGod1223
NORMAL
2022-08-14T05:05:52.716261+00:00
2022-08-14T11:48:54.330411+00:00
421
false
```\nclass Solution {\npublic:\n vector <int> isc[501];\n long dis[501][501];\n int n,tar,as;\n bool jc(string x,string y){\n int v=0;\n for(int i=0;i<x.size();++i)\n if(x[i]!=y[i])++v;\n return v==1;\n }\n vector<vector<string>> findLadders(string bW, string eW, vector...
5
0
['Breadth-First Search']
0
word-ladder-ii
Java Solution using BFS and memorized DFS
java-solution-using-bfs-and-memorized-df-075w
Step1: use BFS to build a Ladder Graph start from beginWord layer and end to endWord layer\nStep2: use memorized DFS to traverse the graph and found all the sho
1005155946
NORMAL
2022-07-07T10:14:54.298885+00:00
2022-07-07T10:14:54.298925+00:00
1,079
false
Step1: use BFS to build a Ladder Graph start from beginWord layer and end to endWord layer\nStep2: use memorized DFS to traverse the graph and found all the shortest route\n``` java\nclass Solution {\n Map<String, List<List<String>>> buf;\n public List<List<String>> findLadders(String beginWord, String endWord, L...
5
1
['Backtracking', 'Depth-First Search', 'Breadth-First Search', 'Java']
1
word-ladder-ii
Python - BFS - very simple
python-bfs-very-simple-by-edgoll-3tpo
\n\n def findLadders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]:\n \n wordList.append(beginWord)\n nei
edgoll
NORMAL
2022-01-26T05:20:10.511728+00:00
2022-01-26T05:20:10.511760+00:00
420
false
![image](https://assets.leetcode.com/users/images/04724cb2-523e-4db6-a855-a78e2ca1608e_1643174123.9432545.png)\n\n def findLadders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]:\n \n wordList.append(beginWord)\n nei = collections.defaultdict(list)\n \n ...
5
0
['Python']
1
word-ladder-ii
Simple Python BFS solution with 20 lines of code and explanation, beats 80%!
simple-python-bfs-solution-with-20-lines-mrzz
Steps:\n1. Construct an adjecncy list from the wordList\n2. Perform normal BFS with a queue (every element is a tuple of currentWord, the list of words from beg
darshangowda0
NORMAL
2020-08-02T06:16:31.179273+00:00
2020-08-02T06:16:31.179306+00:00
470
false
Steps:\n1. Construct an adjecncy list from the wordList\n2. Perform normal BFS with a queue (every element is a tuple of currentWord, the list of words from beginWord to currentWord)\n3. Everytime you find the endWord, add the list built so far to the output list!\n\n**Main STEP to help aviod TLE:**\nDo not visit the s...
5
0
[]
3
word-ladder-ii
C# BFS
c-bfs-by-user638-rcn7
\npublic class Solution\n{\n public IList<IList<string>> FindLadders(string beginWord, string endWord, IList<string> wordList)\n {\n var map = new
user638
NORMAL
2020-04-16T16:18:11.820378+00:00
2020-04-16T16:19:13.934861+00:00
556
false
```\npublic class Solution\n{\n public IList<IList<string>> FindLadders(string beginWord, string endWord, IList<string> wordList)\n {\n var map = new Dictionary<string, List<string>>();\n wordList.Add(beginWord);\n wordList = wordList.Distinct().ToList();\n for (var i = 0; i < wordList...
5
0
['Breadth-First Search']
1
word-ladder-ii
Intuitive Javascript Solution with BFS & DFS
intuitive-javascript-solution-with-bfs-d-rfwf
\n/**\n * @param {string} beginWord\n * @param {string} endWord\n * @param {string[]} wordList\n * @return {string[][]}\n */\nvar findLadders = function(beginWo
dawchihliou
NORMAL
2020-04-12T10:25:21.966823+00:00
2020-04-12T10:25:21.966862+00:00
937
false
```\n/**\n * @param {string} beginWord\n * @param {string} endWord\n * @param {string[]} wordList\n * @return {string[][]}\n */\nvar findLadders = function(beginWord, endWord, wordList) {\n if (!wordList.includes(endWord)) {\n return [];\n }\n \n /**\n * Create an adjacency list and run bfs to cr...
5
0
['Backtracking', 'Depth-First Search', 'Breadth-First Search', 'JavaScript']
3
word-ladder-ii
C++ - solution accepted - only 1-way BFS with comments.
c-solution-accepted-only-1-way-bfs-with-cblz9
The solution passes all tests and accepted.\nAppreciate feedback on how to optimize further.\n\n\nclass Solution {\n public:\n /*\n The idea is to
dcbusc2012
NORMAL
2019-11-28T07:43:15.079036+00:00
2019-11-28T07:43:15.079074+00:00
947
false
The solution passes all tests and accepted.\nAppreciate feedback on how to optimize further.\n\n```\nclass Solution {\n public:\n /*\n The idea is to run a BFS from beginWord to endWord, while keeping track of the path.\n Once the currWord == endWord, we have found the shortest path.\n The ne...
5
0
['C++']
3
minimum-number-of-days-to-disconnect-island
Python [you need at most 2 days]
python-you-need-at-most-2-days-by-gsan-fyec
The tricky part of this question is to notice that, you can disconnect any given island formation in at most 2 days (and you need to convince yourself that this
gsan
NORMAL
2020-08-30T04:02:58.911391+00:00
2024-10-12T10:22:22.584903+00:00
10,868
false
The tricky part of this question is to notice that, you can disconnect any given island formation in at most 2 days (and you need to convince yourself that this is true).\n\n**Day 0:** Check islands at day 0, return 0 if you have less than or greater than one island.\n\n**Day 1**: If not, try to add water at any given ...
200
3
['Python3']
35
minimum-number-of-days-to-disconnect-island
DFS c++ clean code [with explanation]
dfs-c-clean-code-with-explanation-by-m05-keil
Observation\n## ans <= 2\nans is always less-equal to 2\n## why?\nfor any island we can remove the two blocks around the bottom left corner to make it disconnec
m05s
NORMAL
2020-08-30T04:02:32.756442+00:00
2020-09-01T18:03:45.051353+00:00
10,522
false
# Observation\n## **ans <= 2**\nans is always less-equal to 2\n## **why?**\nfor any island we can remove the two blocks around the bottom left corner to make it disconnected\n```\nx x x\nx . x\nx x x\n```\ncan be changed to\n```\nx x x\nx . .\nx . x\n```\nif you still don\'t get it read this: [comment](https://leetcode...
91
3
[]
9
minimum-number-of-days-to-disconnect-island
Easy to Understand | Step by Step Detailed Explaination | Beginner Friendly | Depth-First Search
easy-to-understand-step-by-step-detailed-fzmv
Problem Statement\nWe are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is defined as a maximal 4-directionally conn
tanishqsingh
NORMAL
2024-08-11T01:12:07.143842+00:00
2024-08-11T01:12:07.143869+00:00
27,350
false
# Problem Statement\nWe are given an `m x n` binary grid `grid` where `1` represents land and `0` represents water. An island is defined as a maximal 4-directionally connected group of `1\'s`. The grid is considered connected if there is exactly one island; otherwise, it is disconnected.\n\nOur task is to determine the...
88
2
['Depth-First Search', 'Graph', 'C++', 'Java', 'Python3', 'JavaScript']
8
minimum-number-of-days-to-disconnect-island
✅Beats 100% -Explained with [ Video ] -C++/Java - DFS - Explained in Detail
beats-100-explained-with-video-cjava-dfs-s21z
\n\n# YouTube Video Explanation:\n\n ### To watch the video please click on "Watch On Youtube" option available the left bottom corner of the thumbnail. \n\nIf
lancertech6
NORMAL
2024-08-11T00:44:06.206178+00:00
2024-08-11T00:44:06.206202+00:00
8,948
false
![Screenshot 2024-08-11 060621.png](https://assets.leetcode.com/users/images/ee36b796-cf09-4b43-940d-af86b020e19d_1723336880.943207.png)\n\n# YouTube Video Explanation:\n\n<!-- ### To watch the video please click on "Watch On Youtube" option available the left bottom corner of the thumbnail. -->\n\n**If you want a vid...
61
6
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Strongly Connected Component', 'C++', 'Java']
4
minimum-number-of-days-to-disconnect-island
[Java] Easy to understand
java-easy-to-understand-by-mayank12559-ebub
\nclass Solution {\n public int minDays(int[][] grid) {\n if(noOfIsland(grid) != 1){\n return 0;\n }\n for(int i=0;i<grid.len
mayank12559
NORMAL
2020-08-30T04:08:50.626967+00:00
2020-08-30T04:08:50.627011+00:00
3,068
false
```\nclass Solution {\n public int minDays(int[][] grid) {\n if(noOfIsland(grid) != 1){\n return 0;\n }\n for(int i=0;i<grid.length;i++){\n for(int j=0;j<grid[0].length;j++){\n if(grid[i][j] == 1){\n grid[i][j] = 0;\n if(...
38
1
[]
4
minimum-number-of-days-to-disconnect-island
✅ Easy 3 step C++/ Java / Py / JS Solution | DFS | With Visualization🏆|
easy-3-step-c-java-py-js-solution-dfs-wi-qpj5
Steps:\n1. Check if the Grid is Already Disconnected:\n - Use a function to count the number of islands in the grid.\n - If there is already more than one i
dev_yash_
NORMAL
2024-08-11T01:28:25.878442+00:00
2024-08-11T03:43:12.339586+00:00
4,050
false
### Steps:\n1. **Check if the Grid is Already Disconnected:**\n - Use a function to count the number of islands in the grid.\n - If there is already more than one island, the grid is disconnected, so return `0` days.\n\n2. **Try Removing One Land Cell:**\n - Iterate over each land cell in the grid.\n - For each...
26
1
['Depth-First Search', 'Breadth-First Search', 'Graph', 'C', 'Java', 'Python3', 'JavaScript']
9
minimum-number-of-days-to-disconnect-island
[Python / Golang] There are only 3 possible answers!
python-golang-there-are-only-3-possible-ocm9j
\n## Idea\nHow to make the grid disconnected?\nWe can tell from the first official example that, the worst situation we may get into is to take 2 steps and sepa
yanrucheng
NORMAL
2020-08-30T04:00:49.247784+00:00
2020-08-30T04:09:59.738439+00:00
2,744
false
\n## Idea\n**How to make the grid disconnected?**\nWe can tell from the first official example that, the worst situation we may get into is to take 2 steps and separate a single island out.\nMore specifically, there are 3 situation.\n1. The number of island on the grid is not 1.\n\t- return 0\n1. The number of island o...
25
2
[]
8
minimum-number-of-days-to-disconnect-island
C++ At most 2 removal; Try removing each one and see if the graph is disconnected.
c-at-most-2-removal-try-removing-each-on-q71u
See my latest update in repo LeetCode\n\n## Solution 1.\n\nYou need at most two days to separate out a 1 at the corner with all other 1s. So the answer is one o
lzl124631x
NORMAL
2020-08-30T04:30:15.418062+00:00
2020-08-30T19:19:59.782215+00:00
2,568
false
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1.\n\nYou need at most two days to separate out a `1` at the corner with all other `1`s. So the answer is one of `0`, `1`, `2`.\n\nIf the graph is already disconnected, return `0`.\n\nFor each `1`, see if removing it can disc...
20
0
[]
3
minimum-number-of-days-to-disconnect-island
Most Optimal Approach (Articulation Point) || TC: O(n * m)
most-optimal-approach-articulation-point-j8hd
Intuition\n1. If there are no islands or more than 1 island, than the answer is 0, as we don\'t need to remove anything.\n2. If we can disconnct the island by r
WeirdLogic
NORMAL
2023-11-29T19:02:52.404848+00:00
2023-11-29T19:05:05.741489+00:00
1,196
false
# Intuition\n1. If there are no islands or more than 1 island, than the answer is 0, as we don\'t need to remove anything.\n2. If we can disconnct the island by removing exactly 1 cell, the answer is 1 (will be explaining it shortly in Case 2 of **Approach**).\n3. At last, we can always disconnect an island by removing...
18
0
['Depth-First Search', 'Graph', 'C++']
2
minimum-number-of-days-to-disconnect-island
DFS + test vertices if any neighbor with deg<=2||7ms Beats 93.10%
dfs-test-vertices-if-any-neighbor-with-d-lydd
Intuition\n Describe your first thoughts on how to solve this problem. \nNot optimal, but much better than brute force.\n\nJust consider the vertices with degre
anwendeng
NORMAL
2024-08-11T08:18:33.808770+00:00
2024-08-11T08:36:50.688940+00:00
1,326
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nNot optimal, but much better than brute force.\n\nJust consider the vertices with degree<=2 & its all adjacent vertices.\n\nA vertex here is a cell with 1. A vertex has at most 4 adjacent vertices.\n# Approach\n<!-- Describe your approach...
14
0
['Array', 'Depth-First Search', 'Matrix', 'C++']
2
minimum-number-of-days-to-disconnect-island
[Java] O(MN) 2ms articulation point/bridge approach
java-omn-2ms-articulation-pointbridge-ap-vzob
All the posted solutions are using the similar basic flow: \n1. If there is no island or more than 1 island, return 0;\n2. If there is only one land, return 1;\
caohuicn
NORMAL
2020-08-31T04:57:43.149603+00:00
2020-09-01T00:14:58.620663+00:00
1,607
false
All the posted solutions are using the similar basic flow: \n1. If there is no island or more than 1 island, return 0;\n2. If there is only one land, return 1;\n3. If any single cell could serve as the cut point ( divide 1 island into 2 islands), return 1;\n4. Otherwise, return 2 ( I haven\'t found a formal proof yet)....
13
0
[]
2
minimum-number-of-days-to-disconnect-island
[Python] O(N*M) | Articulation Points | Beats 100%
python-onm-articulation-points-beats-100-4lbt
This question can be divided into 3 cases :\n\n1) The most number of cells to be removed in the worst case will be 2, explained later.\n2) If there is an articu
zypher27
NORMAL
2020-08-30T17:17:11.817957+00:00
2020-09-16T12:47:48.612007+00:00
1,269
false
This question can be divided into 3 cases :\n\n1) The most number of cells to be removed in the worst case will be 2, explained later.\n2) If there is an articulation point, the answer will be 1.\n3) The matrix is already divided or there are no 1\'s, the answer is 0.\n\n\nSo, if you didnt understand the worst case sce...
12
0
['Python']
5
minimum-number-of-days-to-disconnect-island
C++ easy to understand with explanation BFS
c-easy-to-understand-with-explanation-bf-qih4
Looking at the question, it might give an impression as a very difficult question. This question actually is lot easier than it looks. On careful observation, y
mohithakhil
NORMAL
2020-08-30T05:39:31.947800+00:00
2020-08-30T05:42:41.348303+00:00
1,115
false
Looking at the question, it might give an impression as a very difficult question. This question actually is lot easier than it looks. On careful observation, you can notice that the answer can only lie between 0 and 2. \n\nWhen does answer can be 0? If the given matrix already contains more than one island or if the m...
12
3
['Breadth-First Search', 'C']
3
minimum-number-of-days-to-disconnect-island
Beginner Friendly Solution with Brute Force DFS + Visualization + Step Explanation 😊😊
beginner-friendly-solution-with-brute-fo-zs7h
Intuition\nThe problem asks us to find the minimum number of days required to disconnect a single island in a grid. The intuition is to:\n\n1. Identify if there
briancode99
NORMAL
2024-08-10T18:25:43.406718+00:00
2024-08-10T18:25:43.406748+00:00
1,285
false
# Intuition\nThe problem asks us to find the minimum number of days required to disconnect a single island in a grid. The intuition is to:\n\n1. Identify if there are multiple islands: If there are multiple islands, it\'s already disconnected, and we need 0 days.\n2. Disconnect the single island: We need to find a way ...
10
0
['Array', 'Depth-First Search', 'Matrix', 'JavaScript']
3
minimum-number-of-days-to-disconnect-island
Articulation point
articulation-point-by-shivam565-6dus
there are only 3 possible cases:\n\n if the graph already has more than 1 components\n if the graph has atleast one articulation point\n if the graph does\'t fo
shivam565
NORMAL
2022-08-28T09:56:30.718507+00:00
2022-08-28T09:59:05.068957+00:00
915
false
there are only 3 possible cases:\n\n* **if the graph already has more than 1 components**\n* **if the graph has atleast one articulation point**\n* **if the graph does\'t follow those two rules**\n\n\n<br>\n<br>\n<br>\nin the first case the ans is 0 becuse we don\'t need to convert any 1 to 0 because graph is already d...
10
0
['C']
1
minimum-number-of-days-to-disconnect-island
Simplest explanation (with diagram). Articulation Point - Tarjan Algo. Faster than 100%
simplest-explanation-with-diagram-articu-psfz
Now, first of all how many solutions can be there, I will say only 0,1 and 2, why ?\n\n### 1. for \'0\'\na. there is a initially more than one connected compone
himanshuaswal
NORMAL
2021-06-24T10:08:23.965994+00:00
2021-06-24T10:08:23.966041+00:00
2,202
false
# Now, first of all how many solutions can be there, I will say only 0,1 and 2, **why** ?\n\n### 1. for \'0\'\na. there is a initially more than one connected components.\nwhich is quite easy to find, just using a dfs/bfs.\nb. there is no land (all zeroes in grid).\n\n### 2. for \'2\'\n\n at max you can remove 2 connec...
9
0
['Depth-First Search', 'Graph']
5
minimum-number-of-days-to-disconnect-island
Java Clean - Tarjan O(mn)
java-clean-tarjan-omn-by-rexue70-4v1g
This question is similar to question 1192 https://leetcode.com/problems/critical-connections-in-a-network/description/\nwe use tarjan\'s algorithm to record (ev
rexue70
NORMAL
2020-09-01T05:37:42.296311+00:00
2020-09-01T09:27:25.746975+00:00
1,117
false
This question is similar to question 1192 https://leetcode.com/problems/critical-connections-in-a-network/description/\nwe use tarjan\'s algorithm to record (every node) id and the (lowest id it can reach), if we find a critical edge, which means we can cut the island two parts by one cut.\n```\nclass Solution {\n M...
9
1
[]
5
minimum-number-of-days-to-disconnect-island
Python easy
python-easy-by-valkyre_queen-a5v3
The answer can be atmost 2 as \n--->For example number of islands are not 1 we can return 0 as there is no need to do anything\n--->If there is 1 island we can
valkyre_queen
NORMAL
2020-08-30T08:51:32.936553+00:00
2020-09-02T03:49:39.690240+00:00
648
false
The answer can be atmost 2 as \n--->For example number of islands are not 1 we can return 0 as there is no need to do anything\n--->If there is 1 island we can return 1 as 1 step will be sufficient to break them into\n--->If there is 1 island and we cannot break them into 2 islands in 1 day we are left with only one op...
9
2
['Depth-First Search', 'Python']
1
minimum-number-of-days-to-disconnect-island
[Java] Remove at most two
java-remove-at-most-two-by-ycj28c-wk7t
The trick is maximum remove 2 points can get more than two islands.... - -\nThere is always one node in the cornor, for example:\n0 1 1 1 0\n0 1 1 1 0\n0 1 1 1
ycj28c
NORMAL
2020-08-30T04:28:26.288121+00:00
2020-08-30T06:13:14.474362+00:00
1,086
false
The trick is maximum remove 2 points can get more than two islands.... - -\nThere is always one node in the cornor, for example:\n0 1 1 1 0\n0 1 1 1 0\n0 1 1 ***1*** 0\n0 0 0 0 0\nwe can always remove the point next to the right-bottom 1 to get more than 2 island, this case we remove [1,3],[2,2]\n0 1 1 1 0\n0 1 1 0 0\n...
8
0
[]
2
minimum-number-of-days-to-disconnect-island
Easy to understand | Beginner Friendly C++ solution beats 73%
easy-to-understand-beginner-friendly-c-s-b3wr
Intuition\nThe key intuition here is to recognize that we need to find a land cell that, when removed, increases the number of islands. We can achieve this by u
_adarsh_01
NORMAL
2024-08-11T06:22:38.825697+00:00
2024-08-11T06:22:38.825732+00:00
84
false
# Intuition\nThe key intuition here is to recognize that we need to find a land cell that, when removed, increases the number of islands. We can achieve this by using a depth-first search (DFS) to count the number of islands before and after removing each land cell.\n\nBy iterating through each land cell and checking i...
7
0
['Depth-First Search', 'C++']
0
minimum-number-of-days-to-disconnect-island
Easy Java Solution 🚀 Clean Code . . .
easy-java-solution-clean-code-by-niketh_-hfj9
Java Code\n---\n> #### Please don\'t forget to upvote if you\'ve liked my solution. \u2B06\uFE0F\n---\n\nclass Solution {\n int[] xDir = {0,0,-1,1};\n int
niketh_1234
NORMAL
2023-06-14T17:06:14.774840+00:00
2023-06-14T17:06:14.774863+00:00
710
false
# Java Code\n---\n> #### *Please don\'t forget to upvote if you\'ve liked my solution.* \u2B06\uFE0F\n---\n```\nclass Solution {\n int[] xDir = {0,0,-1,1};\n int[] yDir = {-1,1,0,0};\n public boolean isSafe(int[][] grid,int i,int j,boolean[][] visited)\n {\n return(i>=0 && j>=0 && i<grid.length && j...
7
1
['Depth-First Search', 'Recursion', 'C++', 'Java', 'Python3']
2
minimum-number-of-days-to-disconnect-island
[Java] Tarjan 4ms with explain
java-tarjan-4ms-with-explain-by-66brothe-u6jy
Explanation\n1. First let\'s construc a graph\n2. You want to make at least 2 component (if already more than one, just return 0 by doing a simple DFS/BFS check
66brother
NORMAL
2020-08-30T06:28:03.224314+00:00
2020-09-03T13:54:08.497753+00:00
870
false
**Explanation**\n1. First let\'s construc a graph\n2. You want to make at least 2 component (if already more than one, just return 0 by doing a simple DFS/BFS check)\n3. You want to find a cut point (use tarjan algorithm),the cutpoint is the point where it can split the graph if you remove it and all its adjeccent edge...
7
0
[]
5
minimum-number-of-days-to-disconnect-island
Beats 80% || Easy to Understand C++ Code || DFS traversal
beats-80-easy-to-understand-c-code-dfs-t-nuf1
Intuition\n Describe your first thoughts on how to solve this problem. \nThe code checks if the grid of 1s (land) is already disconnected. If not, it tries to d
jitenagarwal20
NORMAL
2024-08-11T08:45:11.630848+00:00
2024-08-11T08:45:11.630872+00:00
689
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe code checks if the grid of 1s (land) is already disconnected. If not, it tries to disconnect the grid by removing one 1 at a time. If removing a single 1 disconnects the grid, it returns 1. Otherwise, if no single removal works, it re...
6
0
['Depth-First Search', 'C++']
2
minimum-number-of-days-to-disconnect-island
🔥 100% beats | DFS or Tarjan's Algorithm |
100-beats-dfs-or-tarjans-algorithm-by-b_-yq3c
Solution 1 (DFS)\n# Intuition\nThe problem aims to find the minimum number of days required to disconnect a grid of islands (where each cell represents a piece
B_I_T
NORMAL
2024-08-11T07:46:27.097331+00:00
2024-08-11T07:49:21.817937+00:00
808
false
# Solution 1 (DFS)\n# Intuition\nThe problem aims to find the minimum number of days required to disconnect a grid of islands (where each cell represents a piece of land or water). The strategy revolves around assessing whether the grid is already disconnected, and if not, determining how quickly the disconnection can ...
6
0
['Array', 'Depth-First Search', 'Matrix', 'Strongly Connected Component', 'Python', 'C++', 'Java', 'JavaScript']
1
minimum-number-of-days-to-disconnect-island
Java BFS
java-bfs-by-hobiter-154x
If you look carefully, the result is 0, 1, or 2;\n1, if num of islands not 1, reutrn 0;\n2, special cases, only one 1 or two 1s;\n3, try to remove any 1 that ha
hobiter
NORMAL
2020-08-30T04:21:06.591932+00:00
2020-08-31T17:34:58.374344+00:00
574
false
If you look carefully, the result is 0, 1, or 2;\n1, if num of islands not 1, reutrn 0;\n2, special cases, only one 1 or two 1s;\n3, try to remove any 1 that has more than 1 neighbors, if it splits the islands, return 1;\n4, otherwise return 2;\n\n```\nclass Solution {\n Queue<int[]> connects;\n public int minDay...
6
3
[]
4
minimum-number-of-days-to-disconnect-island
Runtime beats 72.84%, Memory beats 89.20% [EXPLAINED]
runtime-beats-7284-memory-beats-8920-exp-qise
Intuition\nThe problem is about finding the minimum number of days needed to disconnect a single island in a grid where 1s represent land and 0s represent water
r9n
NORMAL
2024-10-01T02:38:51.679188+00:00
2024-10-01T02:38:51.679228+00:00
11
false
# Intuition\nThe problem is about finding the minimum number of days needed to disconnect a single island in a grid where 1s represent land and 0s represent water. An island is defined as a group of connected 1s, and we want to determine how to remove enough land cells to create multiple islands or completely empty the...
5
0
['TypeScript']
0
minimum-number-of-days-to-disconnect-island
DFS solution with Intuition 🚀| Beginner's Approach
dfs-solution-with-intuition-beginners-ap-3dcx
Intuition\n Describe your first thoughts on how to solve this problem. \nIf we cut an island from any corner leaving smalllest possible island, we need two 0 in
hemantsingh_here
NORMAL
2024-08-11T16:43:40.479488+00:00
2024-08-11T16:43:40.479520+00:00
209
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf we cut an island from any corner leaving smalllest possible island, we need two 0 in diagonal setting. \n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIf number of island is 1, then we flip all 1 to 0 by one ...
5
0
['Depth-First Search', 'C++']
0
minimum-number-of-days-to-disconnect-island
✅✅ BFS Solution || CPP 🚀🚀
bfs-solution-cpp-by-baragemanish6258-jmlj
\n# Code\n\nclass Solution {\npublic:\n int dx[4] = {-1,0,1,0};\n int dy[4] = {0,1,0,-1};\n\n int gc = 0;\n\n int solve(vector<vector<int>>& grid)\n
baragemanish6258
NORMAL
2024-08-11T06:35:16.510545+00:00
2024-08-11T06:35:16.510595+00:00
995
false
\n# Code\n```\nclass Solution {\npublic:\n int dx[4] = {-1,0,1,0};\n int dy[4] = {0,1,0,-1};\n\n int gc = 0;\n\n int solve(vector<vector<int>>& grid)\n {\n int n = grid.size();\n int m = grid[0].size();\n\n vector<vector<int>>vis(n, vector<int>(m, 0));\n queue<pair<int,int>>q;...
5
0
['Array', 'Breadth-First Search', 'Matrix', 'C++']
3
minimum-number-of-days-to-disconnect-island
Python | DFS
python-dfs-by-khosiyat-72pp
see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n def minDays(self, grid: List[List[int]]) -> int:\n def is_connected(grid):\n
Khosiyat
NORMAL
2024-08-11T05:12:30.314191+00:00
2024-08-11T05:12:30.314212+00:00
665
false
[see the Successfully Accepted Submission](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island/submissions/1351676215/?envType=daily-question&envId=2024-08-11)\n\n# Code\n```\nclass Solution:\n def minDays(self, grid: List[List[int]]) -> int:\n def is_connected(grid):\n visite...
5
1
['Python3']
1
minimum-number-of-days-to-disconnect-island
Tarjan's Algorithm
tarjans-algorithm-by-anand_shukla1312-l8vb
Intuition\n Describe your first thoughts on how to solve this problem. \nAn articulation point is a cell that will split an island in two when it is changed fro
anand_shukla1312
NORMAL
2024-08-11T03:40:05.521981+00:00
2024-08-11T03:40:05.522003+00:00
639
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAn articulation point is a cell that will split an island in two when it is changed from land to water. If a given grid has an articulation point, we can disconnect the island in one day. Tarjan\'s algorithm efficiently finds articulation...
5
0
['Java']
2
minimum-number-of-days-to-disconnect-island
notes Explanation ....
notes-explanation-by-ankit1478-mf2s
Intuition\nsorry for Bad Handwriting..\n\n\n\n\n\n# Complexity\n- Time complexity: O(NM) + O(NM) = O(NM)\n Add your time complexity here, e.g. O(n) \n\n- Space
ankit1478
NORMAL
2024-03-05T10:31:42.926434+00:00
2024-03-05T10:32:34.445414+00:00
275
false
# Intuition\nsorry for Bad Handwriting..\n![1.jpg](https://assets.leetcode.com/users/images/f9176610-7a0d-4c5b-9d65-45e76dae6640_1709634509.4716783.jpeg)\n![2.jpg](https://assets.leetcode.com/users/images/926c9ac3-7112-4e94-a476-ac86a72f2b40_1709634529.8163533.jpeg)\n![3.jpg](https://assets.leetcode.com/users/images/08...
5
0
['Depth-First Search', 'Java']
3
minimum-number-of-days-to-disconnect-island
Java || 2 Methods || Brute Force and Articulation Point
java-2-methods-brute-force-and-articulat-zrct
\n // b <================= Minimum Number of Days to Disconnect Island ==========>\n // https://leetcode.com/problems/minimum-number-of-days-to-disconnect
JoseDJ2010
NORMAL
2022-10-20T04:11:46.816692+00:00
2022-10-20T04:13:44.238288+00:00
535
false
```\n // b <================= Minimum Number of Days to Disconnect Island ==========>\n // https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island/\n\n // ! Brute Force, passed since the test case and constraints are small.\n\n public static void dfs_numsIsland(int sr, int sc, int[][] grid...
5
0
['Java']
1
minimum-number-of-days-to-disconnect-island
Easy to understand Clean Code || Depth-First-Search || C++
easy-to-understand-clean-code-depth-firs-j0s9
Intuition\nThe problem is about determining how quickly we can disconnect a single island into two or more separate pieces by changing land cells into water. A
Satvik_Agrawal
NORMAL
2024-08-11T10:41:52.451580+00:00
2024-08-11T10:41:52.451606+00:00
301
false
# Intuition\nThe problem is about determining how quickly we can disconnect a single island into two or more separate pieces by changing land cells into water. A disconnected grid either has multiple islands or no islands at all. The intuition is based on:\n1. **Counting Islands**: If the grid initially has more than o...
4
0
['Depth-First Search', 'C++']
0
minimum-number-of-days-to-disconnect-island
DCC-: 11 AUG 2024 || DFS.
dcc-11-aug-2024-dfs-by-sajaltiwari007-utqa
Problem Intuition and Approach\n\nThe problem aims to determine the minimum number of days required to disconnect an island on a grid by turning one or more lan
sajaltiwari007
NORMAL
2024-08-11T05:35:13.853118+00:00
2024-08-11T05:35:13.853190+00:00
270
false
### Problem Intuition and Approach\n\nThe problem aims to determine the minimum number of days required to disconnect an island on a grid by turning one or more land cells (`1`s) into water (`0`s). The grid is represented by a 2D array, where `1` indicates land and `0` indicates water. An island is a group of connected...
4
0
['Depth-First Search', 'Java']
1
minimum-number-of-days-to-disconnect-island
Most --SIMPLIFIED-- using dfs stack -- EXPLAINED fully
most-simplified-using-dfs-stack-explaine-9lxf
Approach\n Describe your approach to solving the problem. \n\ncheck starting\n\n- count islands: first, count how many separate islands are in the grid. if ther
pawansingh275701
NORMAL
2024-08-11T01:14:25.459794+00:00
2024-08-11T01:14:25.459818+00:00
61
false
# Approach\n<!-- Describe your approach to solving the problem. -->\n\n*check starting*\n\n- **count islands**: first, count how many separate islands are in the grid. if there are already multiple islands (or none), return 0 because no single cell removal is needed to disconnect them.\ntest each cell removal:\n\n---\n...
4
0
['C++']
0
minimum-number-of-days-to-disconnect-island
[Python] Tarjan's Algorithm + Articulation Point detection = at most 2 days of flipping 1s to 0s
python-tarjans-algorithm-articulation-po-s7m6
Intuition\n Describe your first thoughts on how to solve this problem. \nThis is a haaaard problem if you don\'t know that we can take at most 2 days to separat
sinclaire
NORMAL
2023-06-03T13:50:26.138836+00:00
2023-06-03T13:50:26.138884+00:00
202
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis is a haaaard problem if you don\'t know that we can take at most 2 days to separate a given island. We solve this using SCCs concept + articulation point detection.\n\n# Approach\n<!-- Describe your approach to solving the problem. -...
4
0
['Python3']
2
minimum-number-of-days-to-disconnect-island
[C++] 2 solutions, clean code, and detailed explanation
c-2-solutions-clean-code-and-detailed-ex-xg9f
The idea:\nFirst thing to notice is that we need atmost two days to disconnect an island. The intuition is that since diagonal does not count as a connection, g
haoran_xu
NORMAL
2021-07-15T19:31:25.594185+00:00
2021-07-15T19:32:00.175049+00:00
315
false
The idea:\nFirst thing to notice is that we need atmost two days to disconnect an island. The intuition is that since diagonal does not count as a connection, given a corner of the island, we can disconnect two of its connections (in fact it only has two connections) to seperate it. Notice that we can do this to any co...
4
0
[]
0
minimum-number-of-days-to-disconnect-island
No Graphs Beats 100% CPP SOLUTION EASY AND INTUTIVE APPROACH
no-graphs-beats-100-cpp-solution-easy-an-lf7l
Intuition\n Describe your first thoughts on how to solve this problem. \nTo solve this problem, we need to identify the minimum number of days (or steps) requir
Iheretocode
NORMAL
2024-08-11T05:18:00.691095+00:00
2024-08-11T10:41:59.543575+00:00
41
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo solve this problem, we need to identify the minimum number of days (or steps) required to separate the grid into two or more disconnected components or to remove all the land cells entirely.\n\n\n# Approach\n<!-- Describe your approach...
3
0
['C++']
0
minimum-number-of-days-to-disconnect-island
C++ | Minimum Number of Days to Disconnect Island | 62ms
c-minimum-number-of-days-to-disconnect-i-7jiz
Intuition\nTo determine the minimum number of days required to disconnect a single island in a grid, we need to explore how the grid can be split into multiple
user4612MW
NORMAL
2024-08-11T03:35:12.783380+00:00
2024-08-11T03:38:14.531197+00:00
20
false
# Intuition\nTo determine the minimum number of days required to disconnect a single island in a grid, we need to explore how the grid can be split into multiple islands. Each day, we can change one land cell to water, and our goal is to find the minimum number of such changes needed to confirm that the grid is disconn...
3
0
['C++']
0
minimum-number-of-days-to-disconnect-island
Easy to understand ✅ Python, C# 🔥 | Great runtime ✨
easy-to-understand-python-c-great-runtim-e79o
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires finding the minimum number of days needed to disconnect a land mas
kotto
NORMAL
2024-08-11T00:10:55.852950+00:00
2024-08-11T00:10:55.852968+00:00
632
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires finding the minimum number of days needed to disconnect a land mass in a grid. My initial thought is to explore whether the grid is already disconnected, and if not, determine how quickly it can be split into separate...
3
0
['Depth-First Search', 'Matrix', 'Python3', 'C#']
3
minimum-number-of-days-to-disconnect-island
C++ DFS solution
c-dfs-solution-by-sachin_kumar_sharma-p3bl
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Sachin_Kumar_Sharma
NORMAL
2024-04-18T03:56:25.886862+00:00
2024-04-18T03:56:25.886885+00:00
9
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O((m*n)^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(m*n)\n<!-- Add your space complexity here...
3
0
['C++']
0
minimum-number-of-days-to-disconnect-island
Easy BFS Solution || C++ || Number of Island
easy-bfs-solution-c-number-of-island-by-wxvj7
\nclass Solution {\nprivate:\n int totalLand(vector<vector<int>>& grid)\n {\n int n = grid.size() , m = grid[0].size();\n vector<vector<int>
RIOLOG
NORMAL
2023-10-26T15:31:46.201594+00:00
2023-10-26T15:31:46.201626+00:00
712
false
```\nclass Solution {\nprivate:\n int totalLand(vector<vector<int>>& grid)\n {\n int n = grid.size() , m = grid[0].size();\n vector<vector<int>>vis(n,vector<int>(m,0));\n int count = 0;\n\n for (int i=0;i<n;i++)\n {\n for (int j=0;j<m;j++)\n {\n ...
3
0
['Breadth-First Search', 'C++']
1
minimum-number-of-days-to-disconnect-island
C++| BFS | islands-problems | Easy-to-understand
c-bfs-islands-problems-easy-to-understan-638j
Intuition\n Describe your first thoughts on how to solve this problem. \nAll the posted solutions are using the similar basic flow:\n\n- If there is no island o
sko_1
NORMAL
2022-12-14T07:15:42.753048+00:00
2022-12-14T07:15:42.753093+00:00
741
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAll the posted solutions are using the similar basic flow:\n\n- If there is no island or more than 1 island, return 0;\n- If there is only one land, return 1;\n- If any single cell could serve as the cut point ( divide 1 island into 2 isl...
3
0
['C++']
1
minimum-number-of-days-to-disconnect-island
C++ | islands-problems | medium-hard
c-islands-problems-medium-hard-by-chikzz-3q08
PLEASE UPVOTE IF YOU FIND MY SOLUTION HELPFUL\n\n\nclass Solution {\n int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};\n bool vis[31][31];\n int noOfIslands(
chikzz
NORMAL
2022-03-30T05:35:34.216282+00:00
2022-03-30T05:35:34.216307+00:00
534
false
**PLEASE UPVOTE IF YOU FIND MY SOLUTION HELPFUL**\n\n```\nclass Solution {\n int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};\n bool vis[31][31];\n int noOfIslands(vector<vector<int>>& grid,int &n,int &m)\n {\n int islands=0;\n memset(vis,0,sizeof(vis));\n for(int i=0;i<n;i++)\n {\n ...
3
0
['Depth-First Search', 'Recursion']
1
minimum-number-of-days-to-disconnect-island
C++, Articulation Point O(m + n)
c-articulation-point-om-n-by-level7-hnwc
Guys, Comment me if you have any questions, Approach is pretty similar to AP but we need to consider some corner cases as well, \nCase 1 : there is only one isl
level7
NORMAL
2021-08-09T22:12:20.994331+00:00
2022-01-06T20:42:21.610991+00:00
725
false
Guys, Comment me if you have any questions, Approach is pretty similar to AP but we need to consider some corner cases as well, \nCase 1 : there is only one island and one land return 1\nCase 2 : if no of islands are more than one -> in this case we need to return 0;\nCase 3: there is only one island and two lands retu...
3
0
['C']
2
minimum-number-of-days-to-disconnect-island
C++ DFS 1/4 Positive
c-dfs-14-positive-by-votrubac-vrtc
The answer is:\n1. Zero if there is no islands or more than one island.\n2. One when there is a single piece of land that connects two or more semi-islands. \n3
votrubac
NORMAL
2020-09-01T01:48:01.181210+00:00
2020-09-01T01:58:59.187254+00:00
139
false
The answer is:\n1. Zero if there is no islands or more than one island.\n2. One when there is a single piece of land that connects two or more semi-islands. \n3. Two otherwise.\n\nHow to tell if a land connects semi-islands? If it does not, doing DFS in one direction will explore the entire island. If it does, we need ...
3
3
[]
0
minimum-number-of-days-to-disconnect-island
[JavaScript] Find the critical points and check O(MNK) (K: number of critical point)
javascript-find-the-critical-points-and-t29rk
The maximum answer could only be 2.\nEx:\n0111\n0111\n0111\n0000\n-->\n0111\n0011\n0101\n0000\n\nSince we know this rule. Now we have to do the following steps:
alanchanghsnu
NORMAL
2020-08-30T04:02:23.381740+00:00
2020-08-30T04:12:54.952013+00:00
386
false
The maximum answer could only be 2.\nEx:\n0111\n0111\n0111\n0000\n-->\n0111\n0011\n0101\n0000\n\nSince we know this rule. Now we have to do the following steps:\n1. Is it only one island?\n\tYes: Go next Step\n\tNo: return 0\n2. In the step 1, you can check which land connect 2 lands at most\n If connect 1 land, ret...
3
0
['JavaScript']
1
minimum-number-of-days-to-disconnect-island
easy solution
easy-solution-by-paramdotcom-mwo1
\n\n#include <bits/stdc++.h>\nusing namespace std;\n\nclass Solution\n{\npublic:\n void bfs(vector<vector<int>> &grid, int i, int j, int check)\n {\n
paramdotcom
NORMAL
2024-08-11T17:04:40.627851+00:00
2024-08-11T17:04:40.627895+00:00
10
false
\n```\n#include <bits/stdc++.h>\nusing namespace std;\n\nclass Solution\n{\npublic:\n void bfs(vector<vector<int>> &grid, int i, int j, int check)\n {\n if (i - 1 >= 0 && grid[i - 1][j] == check)\n {\n grid[i - 1][j] = check + 1;\n bfs(grid, i - 1, j, check);\n }\n ...
2
0
['C++']
0
minimum-number-of-days-to-disconnect-island
Easy for Beginner || Simple Approach || Full Explanation
easy-for-beginner-simple-approach-full-e-q9e7
Approach\nHere\'s the approach:\n\nDepth-First Search (DFS): The dfs function is used to traverse the grid in a depth-first manner. It starts from a cell (i, j)
Rohan_k14
NORMAL
2024-08-11T13:34:19.718269+00:00
2024-08-11T13:34:19.718300+00:00
171
false
# Approach\nHere\'s the approach:\n\nDepth-First Search (DFS): The dfs function is used to traverse the grid in a depth-first manner. It starts from a cell (i, j), and if the cell is within the grid boundaries, not visited before, and is land (grid[i][j] == 1), it marks it as visited and continues the search in all fou...
2
0
['C++']
1
minimum-number-of-days-to-disconnect-island
Easy Solution in C
easy-solution-in-c-by-tamilarasanmurugan-kjf5
Intuition\nThe problem is about determining the minimum number of operations (days) needed to disconnect a grid by removing cells. The goal is to break the grid
TamilarasanMurugan
NORMAL
2024-08-11T13:05:32.203190+00:00
2024-08-11T13:05:32.203216+00:00
15
false
# Intuition\nThe problem is about determining the minimum number of operations (days) needed to disconnect a grid by removing cells. The goal is to break the grid into multiple islands by removing as few cells as possible.\n\n# Approach\n1.Initial Island Check: First, check if the grid is already disconnected. If it is...
2
0
['Array', 'Depth-First Search', 'Breadth-First Search', 'C', 'Matrix', 'Strongly Connected Component']
0
minimum-number-of-days-to-disconnect-island
DFS || C++ || Clean Code & Easy Solution
dfs-c-clean-code-easy-solution-by-zishan-5him
Code\n\nclass Solution {\npublic:\n int n, m;\n int vis[31][31];\n vector<pair<int, int> > dir = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};\n\n bool isVali
zishan_0point1
NORMAL
2024-08-11T09:09:42.989121+00:00
2024-08-11T09:09:42.989152+00:00
121
false
# Code\n```\nclass Solution {\npublic:\n int n, m;\n int vis[31][31];\n vector<pair<int, int> > dir = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};\n\n bool isValid(int r, int c){\n return r >= 0 && r < n && c >= 0 && c < m;\n }\n void dfs(int x, int y, vector<vector<int>>& grid){\n vis[x][y] = 1;...
2
0
['Depth-First Search', 'Matrix', 'C++']
0
minimum-number-of-days-to-disconnect-island
Easy to understand ||BFS || Beats 70% || C++
easy-to-understand-bfs-beats-70-c-by-har-apnv
Intuition\n Describe your first thoughts on how to solve this problem. \nThe bfs or dfs function is used to mark all connected land cells starting from a given
hardik-chauhan
NORMAL
2024-08-11T07:19:15.627841+00:00
2024-08-11T07:19:15.627885+00:00
61
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe bfs or dfs function is used to mark all connected land cells starting from a given cell as visited. The isConnected function checks if all land cells are connected by using the bfs function. The minDays function first checks if the gr...
2
0
['C++']
0
minimum-number-of-days-to-disconnect-island
C++ || DFS
c-dfs-by-akash92-xs3s
Intuition\n Describe your first thoughts on how to solve this problem. \nNo matter what, we can always disconnect islands in 2 days at max.\nHow so?\nin a group
akash92
NORMAL
2024-08-11T06:52:12.827911+00:00
2024-08-11T06:52:12.827951+00:00
417
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nNo matter what, we can always disconnect islands in 2 days at max.\nHow so?\nin a group of islands, delete the two islands(right and bottom) of the top left corner island.\nthis means we need to check if it can be done in less than 2 days...
2
0
['Depth-First Search', 'Matrix', 'C++']
1
minimum-number-of-days-to-disconnect-island
BRUTE FOCE SOLUTION || DFS || WITH EXPLANATION
brute-foce-solution-dfs-with-explanation-uzfb
Intuition\n Describe your first thoughts on how to solve this problem. \n1. Connected Components (Islands): An island is a group of connected land cells (1s). C
ManaviArora
NORMAL
2024-08-11T06:26:01.697355+00:00
2024-08-11T06:26:01.697389+00:00
104
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. `Connected Components (Islands):` An island is a group of connected land cells (1s). Connectivity is defined in the four cardinal directions: up, down, left, and right.\n2. `Island Removal Impact:` By removing one cell, you might eithe...
2
0
['Array', 'Depth-First Search', 'Matrix', 'Strongly Connected Component', 'C++']
1
minimum-number-of-days-to-disconnect-island
🌟 Mastering Island Disconnect in 2 Days with Multi-Language Solutions 🔥💯
mastering-island-disconnect-in-2-days-wi-5ynj
\n\nExplore a collection of solutions to LeetCode problems in multiple programming languages. Each solution includes a detailed explanation and step-by-step app
withaarzoo
NORMAL
2024-08-11T06:01:55.528465+00:00
2024-08-11T06:01:55.528565+00:00
504
false
![Screenshot 2024-07-02 113653.png](https://assets.leetcode.com/users/images/0fe22215-9477-4dea-98ba-462c80c91754_1723355730.0397148.png)\n\nExplore a collection of solutions to LeetCode problems in multiple programming languages. Each solution includes a detailed explanation and step-by-step approach to solving the pr...
2
0
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Python', 'C++', 'Java', 'Go', 'Python3', 'JavaScript']
2
minimum-number-of-days-to-disconnect-island
Java Solution Using GraphBFS Traversal || SCC Typically Question
java-solution-using-graphbfs-traversal-s-6tr7
Complexity\n- Time complexity:O((n+m)*4Alpha)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:\n Add your space complexity here, e.g. O(n) \n\
Shree_Govind_Jee
NORMAL
2024-08-11T04:15:25.728138+00:00
2024-08-11T04:15:25.728163+00:00
277
false
# Complexity\n- Time complexity:$$O((n+m)*4Alpha)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n\n int[] dir_X = { 1, -1, 0, 0 };\n int[] dir_Y = { 0, 0, 1, -1 };\n\n private void solveBF...
2
0
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Strongly Connected Component', 'Java']
2
minimum-number-of-days-to-disconnect-island
C++ || Easy Video Solution
c-easy-video-solution-by-n_i_v_a_s-o57k
The video solution for the below code is\nhttps://youtu.be/dDfY6llzsu8\n\n# Code\n\nclass Solution {\npublic:\n int minDays(vector<vector<int>>& grid) {\n
__SAI__NIVAS__
NORMAL
2024-08-11T04:08:34.745360+00:00
2024-08-11T04:08:34.745377+00:00
436
false
The video solution for the below code is\nhttps://youtu.be/dDfY6llzsu8\n\n# Code\n```\nclass Solution {\npublic:\n int minDays(vector<vector<int>>& grid) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n // Note : Grid is said to be connected if there is excatly o...
2
0
['C++']
1
minimum-number-of-days-to-disconnect-island
C# Solution for Minimum Number of Days to Disconnect Island Problem
c-solution-for-minimum-number-of-days-to-s9kt
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this approach is to treat the grid as a graph where each cell repr
Aman_Raj_Sinha
NORMAL
2024-08-11T03:04:08.313763+00:00
2024-08-11T03:04:08.313789+00:00
122
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this approach is to treat the grid as a graph where each cell represents a node. The idea is to identify \u201Ccritical cells\u201D (similar to bridges in graph theory) that, when removed, increase the number of islan...
2
0
['C#']
1
minimum-number-of-days-to-disconnect-island
Swift | 2 days are enough 🏄
swift-2-days-are-enough-by-pagafan7as-0fkn
The key to solving this problem is to notice that the solution is either 0, 1 or 2 days.\n\nProof: If there is at least one square with land, go up and right as
pagafan7as
NORMAL
2024-08-11T01:07:30.411385+00:00
2024-08-11T02:38:37.340870+00:00
48
false
The key to solving this problem is to notice that the solution is either 0, 1 or 2 days.\n\n**Proof:** If there is at least one square with land, go up and right as long as there is land. You will end up at a land square from where you cannot proceed, with water above and to the right. This land square can be made disc...
2
0
['Swift']
0
minimum-number-of-days-to-disconnect-island
Easy Solution
easy-solution-by-sachinonly-j8mo
Intuition\nview the hint section and for better understanding view editorial\n\n# Approach\n1. Count Islands:\n - A helper function countIslands is used to c
Sachinonly__
NORMAL
2024-08-11T00:44:32.717920+00:00
2024-08-11T12:07:16.313422+00:00
371
false
# Intuition\nview the hint section and for better understanding view editorial\n\n# Approach\n1. **Count Islands:**\n - A helper function countIslands is used to count the number of islands in the grid using Depth-First Search (DFS).\n - It initializes a visited matrix to keep track of visited cells and a counter...
2
0
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Strongly Connected Component', 'Python', 'C++', 'Python3']
1
minimum-number-of-days-to-disconnect-island
O(m * n) | DFS | Beats 100% Java | C++ | Python | Go | Rust | JavaScript
om-n-dfs-beats-100-java-c-python-go-rust-szcp
Intuition\n\nThis problem is fundamentally a graph theory problem. The key insight is to recognize that we\'re dealing with a connected component (the island) i
kartikdevsharma_
NORMAL
2024-08-09T12:05:23.305727+00:00
2024-08-09T12:41:04.281545+00:00
358
false
### Intuition\n\nThis problem is fundamentally a graph theory problem. The key insight is to recognize that we\'re dealing with a connected component (the island) in a graph (the grid), and we need to find the most efficient way to break this component.\n\nInitially, one might think of simply removing land cells one by...
2
1
['Array', 'Depth-First Search', 'Breadth-First Search', 'C++', 'Java', 'Go', 'Python3', 'Rust', 'JavaScript']
1
minimum-number-of-days-to-disconnect-island
Minimum Number of Days to Disconnect Island - JAVA
minimum-number-of-days-to-disconnect-isl-d2xr
Intuition\n Describe your first thoughts on how to solve this problem. \nDFS , Matrix - Flip\n\n\n# Complexity\n- Time complexity: O ( m * n )\n Add your time c
Shyam2626
NORMAL
2024-01-07T07:41:01.465211+00:00
2024-01-07T07:41:01.465242+00:00
247
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDFS , Matrix - Flip\n\n\n# Complexity\n- Time complexity: O ( m * n )\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O ( m * n )\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass ...
2
0
['Depth-First Search', 'Matrix', 'Java']
1
minimum-number-of-days-to-disconnect-island
Simple Dfs||C++||Easy
simple-dfsceasy-by-aayushi_kukreja-hxdy
\n\n# Code\n\nclass Solution {\npublic:\n void dfs(int row,int col,vector<vector<int>>& grid,vector<vector<int>>&vis)\n {\n int n = grid.size();\n
Aayushi_Kukreja
NORMAL
2023-02-27T18:27:57.715859+00:00
2023-02-27T18:27:57.715899+00:00
182
false
\n\n# Code\n```\nclass Solution {\npublic:\n void dfs(int row,int col,vector<vector<int>>& grid,vector<vector<int>>&vis)\n {\n int n = grid.size();\n int m = grid[0].size();\n vis[row][col]=1;\n int delrow[] = {1, -1, 0, 0};\n int delcol[] = {0, 0, 1, -1};\n\n for(int i=0...
2
0
['C++']
0
minimum-number-of-days-to-disconnect-island
Tarjan's algorithm: O(m * n) with approach and detailed comments 💯
tarjans-algorithm-om-n-with-approach-and-4ajh
Intuition\n Describe your first thoughts on how to solve this problem. \nThe DFS function uses Tarjan\'s algorithm to identify the articulation points in the gr
abdulahadsiddiqui11
NORMAL
2022-12-26T05:47:41.136869+00:00
2022-12-26T05:47:41.136909+00:00
197
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe DFS function uses Tarjan\'s algorithm to identify the articulation points in the grid. It keeps track of the insertion time and lowest time of each cell, which are used to determine whether a cell is an articulation point. The inserti...
2
0
['Depth-First Search', 'C++']
0
minimum-number-of-days-to-disconnect-island
[C++] | The Only Observation to Solve the Problem
c-the-only-observation-to-solve-the-prob-sure
You will need at most 2 days.\n\nProof: you can always just isolate the 1 in the corner by making his 2 neighbours equal to zero.\n\nSo, first we will check the
makhonya
NORMAL
2022-06-11T12:35:49.804473+00:00
2022-06-11T12:35:49.804511+00:00
223
false
`You will need at most 2 days.`\n\nProof: you can always just isolate the ```1``` in the corner by making his 2 neighbours equal to zero.\n\nSo, first we will check the number of islands we have, if it is more than 1 we return 0, because islands are already disconnected. If it is equal to 1, we will replace each of 1\'...
2
0
['Depth-First Search', 'C', 'C++']
1
minimum-number-of-days-to-disconnect-island
C++ | Similar to Finding Articulation Point | Explained
c-similar-to-finding-articulation-point-e640x
I\'ll tell you the steps:\n1) Convert the grid into a graph.\n2) If there is only one 1, then you need to remove it (because connected definition says only 1 is
harshnadar23
NORMAL
2021-09-15T08:46:04.470890+00:00
2021-09-15T08:46:04.470924+00:00
635
false
I\'ll tell you the steps:\n1) Convert the grid into a graph.\n2) If there is only one 1, then you need to remove it (because connected definition says only 1 island)\n3) Find number of connected components\n4) If connected components>1 return 0\n5) Find articulation point\n6) If articulation point is present, then retu...
2
1
['Depth-First Search', 'C']
0
minimum-number-of-days-to-disconnect-island
JAVA DFS(Connected Components) With Comments
java-dfsconnected-components-with-commen-xv6g
\nclass Solution {\n static int [][]dirs={{-1,0},{0,1},{0,-1},{1,0}};\n public void connectedComponents(int[][] grid, int i, int j, boolean[][] visited) {
abhirajsinha
NORMAL
2021-08-16T06:18:26.060514+00:00
2021-08-16T15:12:02.804280+00:00
448
false
```\nclass Solution {\n static int [][]dirs={{-1,0},{0,1},{0,-1},{1,0}};\n public void connectedComponents(int[][] grid, int i, int j, boolean[][] visited) {\n \n visited[i][j] = true;\n for(int d=0;d<4;d++){\n int r=i+dirs[d][0];\n int c=j+dirs[d][1];\n \n ...
2
1
['Depth-First Search', 'Java']
2
minimum-number-of-days-to-disconnect-island
Java | Easy | DFS | Using Number of Islands
java-easy-dfs-using-number-of-islands-by-065d
\nclass Solution {\n public int minDays(int[][] grid) {\n int n = grid.length ;\n int m = grid[0].length ;\n if(numIslands(grid) != 1){\
user8540kj
NORMAL
2021-08-05T13:01:24.194275+00:00
2021-08-05T13:01:24.194307+00:00
202
false
```\nclass Solution {\n public int minDays(int[][] grid) {\n int n = grid.length ;\n int m = grid[0].length ;\n if(numIslands(grid) != 1){\n return 0;\n }\n for(int i = 0; i < n;i++ ){\n for(int j = 0 ; j < m ; j++){\n if(grid[i][j] == 1){\n ...
2
0
[]
0
minimum-number-of-days-to-disconnect-island
BFS C++ Approach
bfs-c-approach-by-codes_aman-nsj5
\nclass Solution {\npublic:\n int dx[4]={-1,0,1,0};\n int dy[4]={0,1,0,-1};\n bool safe(int x,int y,int m,int n)\n {\n return (x>=0&&x<m&&y>=
codes_aman
NORMAL
2020-11-28T13:30:36.520036+00:00
2020-11-28T13:30:36.520065+00:00
338
false
```\nclass Solution {\npublic:\n int dx[4]={-1,0,1,0};\n int dy[4]={0,1,0,-1};\n bool safe(int x,int y,int m,int n)\n {\n return (x>=0&&x<m&&y>=0&&y<n);\n }\n void travel(int i,int j,vector<vector<int> > &grid,vector<vector<int> > &visited)\n {\n int m=grid.size();\n int n=grid...
2
0
['Breadth-First Search', 'C']
1
minimum-number-of-days-to-disconnect-island
Easy C++ solution, with full explanation
easy-c-solution-with-full-explanation-by-shop
Connected Components\nLook closely, the answer of the question can not be greater than 2.\n\nAlgo:\n1. First Check if the connected components are already great
hiteshgupta
NORMAL
2020-08-30T04:13:16.635256+00:00
2020-08-30T04:13:58.922717+00:00
302
false
# Connected Components\n**Look closely, the answer of the question can not be greater than 2.**\n\nAlgo:\n1. First Check if the connected components are already greater than 1, if yes return 0\n2. Then do the following:\n for every grid value of 1, set it up for 0, check connected components, if connect components a...
2
0
['Breadth-First Search', 'Graph', 'C']
2
minimum-number-of-days-to-disconnect-island
C#
c-by-adchoudhary-sgjr
Code
adchoudhary
NORMAL
2025-03-08T03:19:06.783071+00:00
2025-03-08T03:19:06.783071+00:00
2
false
# Code ```csharp [] public class Solution { public int MinDays(int[][] grid) { // Step 1: Check if the grid is already disconnected. if (CountIslands(grid) != 1) { return 0; } // Step 2: Check for bridge-like cells. int rows = grid.Length; int cols = grid[0].L...
1
0
['C#']
0
minimum-number-of-days-to-disconnect-island
Using Tarjan's Algorithm(if only one component)
using-tarjans-algorithmif-only-one-compo-oe2j
Intuition \n1. If there are no islands or more than 1 island, than the answer is 0, as we don\'t need to remove anything.\n2. If we can disconnct the island by
keshavchauhan107
NORMAL
2024-08-12T08:33:27.788330+00:00
2024-08-12T08:33:27.788357+00:00
5
false
# Intuition \n1. If there are no islands or more than 1 island, than the answer is 0, as we don\'t need to remove anything.\n2. If we can disconnct the island by removing exactly 1 cell, the answer is 1 (will be finding Articulation point using Tarjan\'s Algorithm).\n3. At last, we can always disconnect an island by re...
1
0
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Strongly Connected Component', 'C++']
0
minimum-number-of-days-to-disconnect-island
C++,DFS
cdfs-by-daredreamer-7stk
Intuition\njust try to count diagonal one connected to one single source\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nDFS\n Desc
daredreamer
NORMAL
2024-08-11T20:12:36.004778+00:00
2024-08-11T20:12:36.004797+00:00
23
false
> # Intuition\njust try to count diagonal one connected to one single source\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nDFS\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Sp...
1
0
['Depth-First Search', 'C++']
0
minimum-number-of-days-to-disconnect-island
Simple Logic, Just observe and dry run few test cases
simple-logic-just-observe-and-dry-run-fe-kf4p
Intuition\n1. If Initial number of Islands are greater than 1 or equal to zero return 0.\n2. Now change one by one each 1 to 0, count the number of new islands
Hardy1
NORMAL
2024-08-11T19:31:30.676454+00:00
2024-08-11T19:31:30.676491+00:00
25
false
# Intuition\n1. If Initial number of Islands are greater than 1 or equal to zero return 0.\n2. Now change one by one each 1 to 0, count the number of new islands and replace 0 with 1. If new islands greater than 1 or equal to 0 then return 1.\n3. In the worst case like this [[1,1,1],[1,1,1],[1,1,1]] here you can see ch...
1
0
['Depth-First Search', 'Matrix', 'C++']
0
minimum-number-of-days-to-disconnect-island
Simple Explanation
simple-explanation-by-aayushbharti-n74h
Intuition\nTo disconnect an island, you need to break the connectivity of the land cells. This can be done by either removing a single land cell or, if the isla
AayushBharti
NORMAL
2024-08-11T18:44:35.251315+00:00
2024-08-11T18:44:35.251344+00:00
17
false
# Intuition\nTo disconnect an island, you need to break the connectivity of the land cells. This can be done by either removing a single land cell or, if the island is very connected, you might need to remove two or more. The minimum number of days is determined by the number of cells that need to be removed to disconn...
1
0
['Java']
0
minimum-number-of-days-to-disconnect-island
C# Beats 100% with 113 ms
c-beats-100-with-113-ms-by-zocolini-mazy
Intuition\nFirst we can prove that the maximun number of days needed is 2. We also can prove that for islands of 1, 2 or 3 lands we already know the number o da
zocolini
NORMAL
2024-08-11T17:25:01.572232+00:00
2024-08-11T17:25:01.572266+00:00
11
false
# Intuition\nFirst we can prove that the maximun number of days needed is 2. We also can prove that for islands of 1, 2 or 3 lands we already know the number o days needed.\n\n# Approach\nWe first check the number os 1s to discard those cases that we already know how they end. Next step it\'s try to find one bridge poi...
1
0
['C#']
0
minimum-number-of-days-to-disconnect-island
✨[TYPESCRIPT]✨ 140 ms Beats 79.37% ✅
typescript-140-ms-beats-7937-by-rain84-nxpl
Intuition\n\nThere is a lot of LOC\'s, but it is not a most complicated solution.\nRealy. \n\n# Approach\n\n1. Use dfs and use it to count the number of "island
rain84
NORMAL
2024-08-11T17:18:29.327404+00:00
2024-08-13T08:04:22.301155+00:00
30
false
# Intuition\n\nThere is a lot of LOC\'s, but it is not a most complicated solution.\nRealy. \n\n# Approach\n\n1. Use dfs and use it to count the number of "islands"\n2. If there are 0 islands or more than the 1st, it means that nothing in the matrix needs to be changed and we return a zero\n3. Go through the "island" c...
1
0
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'TypeScript', 'JavaScript']
0
minimum-number-of-days-to-disconnect-island
Easy to understand C++ solution with comments.
easy-to-understand-c-solution-with-comme-tivb
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
BhavyaGautam899
NORMAL
2024-08-11T17:10:54.143429+00:00
2024-08-11T17:10:54.143461+00:00
15
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Depth-First Search', 'C++']
0
minimum-number-of-days-to-disconnect-island
solution -python
solution-python-by-shrutisingh64-unmb
Intuition\nThe grid consists of 1s (land) and 0s (water)\nThe goal is to find the minimum number of days required to disconnect the island, meaning that no two
shrutisingh64
NORMAL
2024-08-11T16:17:54.587525+00:00
2024-08-11T16:17:54.587558+00:00
48
false
# Intuition\nThe grid consists of 1s (land) and 0s (water)\nThe goal is to find the minimum number of days required to disconnect the island, meaning that no two 1s are connected.\nIn one day, you can remove one 1 (land cell) from the grid.\nAfter removing a 1, the grid is updated, and the remaining 1s may become disco...
1
0
['Python3']
0
minimum-number-of-days-to-disconnect-island
C++ Approach || Time complexity O(m*n)^2 & space complexity O(m&n) || Simple Dfs Approach
c-approach-time-complexity-omn2-space-co-a3j6
Complexity\n- Time complexity:O(mn)^2\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(mn)\n Add your space complexity here, e.g. O(n) \n\n#
sneha029
NORMAL
2024-08-11T16:15:52.227596+00:00
2024-08-11T16:15:52.227625+00:00
35
false
# Complexity\n- Time complexity:O(m*n)^2\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(m*n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int m, n;\n void dfs(vector<vector<int>>& grid, int i, int j, vector<vector<bool>>& vis){...
1
0
['C++']
0
minimum-number-of-days-to-disconnect-island
🧠✅ PYTHON SIMPLE SOLUTION EXPLAINED IN DETAILS ✔️🔥🧠
python-simple-solution-explained-in-deta-wgln
\n## Intuition \uD83E\uDD14\nThe key to solving this problem is to understand that we need to find the minimum number of days required to disconnect the grid, w
sagarsaini_
NORMAL
2024-08-11T14:08:07.972986+00:00
2024-08-11T14:08:07.973020+00:00
12
false
\n## Intuition \uD83E\uDD14\nThe key to solving this problem is to understand that we need to find the minimum number of days required to disconnect the grid, which means we need to find the minimum number of cells that, when changed from land to water, will result in the grid having more than one island or no islands ...
1
0
['Array', 'Depth-First Search', 'Matrix', 'Strongly Connected Component', 'Python3']
0
minimum-number-of-days-to-disconnect-island
Easy solution | Step by Step Detailed Full Solution | C++ Solution
easy-solution-step-by-step-detailed-full-j8xl
For the full code, check at bottom. \n### Problem Understanding:\nYou have a grid where each cell is either land (1) or water (0). The goal is to determine the
aizagazyani16
NORMAL
2024-08-11T13:38:59.921533+00:00
2024-08-11T13:38:59.921561+00:00
17
false
> # For the full code, check at bottom. \n### Problem Understanding:\nYou have a grid where each cell is either land (1) or water (0). The goal is to determine the minimum number of days needed to disconnect an island in the grid. An island is defined as a group of connected land cells (horizontally or vertically). \n\...
1
0
['C++']
0
minimum-number-of-days-to-disconnect-island
✅EASY JAVA SOLUTION BEATS 100%
easy-java-solution-beats-100-by-swayam28-btvi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
swayam28
NORMAL
2024-08-11T13:38:46.957869+00:00
2024-08-11T13:38:46.957898+00:00
53
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Java']
0
minimum-number-of-days-to-disconnect-island
DFS Brute-Force Beats 78%
dfs-brute-force-beats-78-by-robin_rathor-9wuj
\n# Code\n\nclass Solution {\n private:\n void dfs(vector<vector<int>>& temp, int i, int j){\n if(i < 0 || j < 0 || i >= temp.size() || j >= temp[i
Robin_Rathore
NORMAL
2024-08-11T13:24:21.814288+00:00
2024-08-11T13:24:21.814314+00:00
24
false
\n# Code\n```\nclass Solution {\n private:\n void dfs(vector<vector<int>>& temp, int i, int j){\n if(i < 0 || j < 0 || i >= temp.size() || j >= temp[i].size() || temp[i][j] == 0) return;\n\n if(temp[i][j])\n temp[i][j] = 0;\n dfs(temp, i+1, j);\n dfs(temp, i, j+1);\n dfs(...
1
0
['C++']
0
minimum-number-of-days-to-disconnect-island
Minimum Number of Days to Disconnect Island: Efficient DFS-Based Solution
minimum-number-of-days-to-disconnect-isl-dm0y
Intuition\nIn this problem, the goal is to determine the minimum number of days required to disconnect an island, where an island is defined as a connected grou
ruturaj_dm
NORMAL
2024-08-11T12:52:02.575443+00:00
2024-08-11T12:53:35.154759+00:00
31
false
# Intuition\nIn this problem, the goal is to determine the minimum number of days required to disconnect an island, where an island is defined as a connected group of land cells (1s) in a grid.\n\n# Approach:\n1. Initial Check: We first count the number of islands in the grid. If the island count is not exactly one, th...
1
0
['Java']
0
minimum-number-of-days-to-disconnect-island
EASY CODE EXPLAINED || Disconnecting a Grid: Minimum Days to Disconnect Land Cells in a Matrix
easy-code-explained-disconnecting-a-grid-85dv
Problem Statement\nThe function minDays determines the minimum number of days required to disconnect a grid (represented as a 2D list) into two or more disconne
Person_UK
NORMAL
2024-08-11T11:52:36.424717+00:00
2024-08-11T11:52:36.424740+00:00
39
false
# Problem Statement\nThe function minDays determines the minimum number of days required to disconnect a grid (represented as a 2D list) into two or more disconnected components by removing land cells. The grid consists of land cells (represented by 1s) and water cells (represented by 0s).\n\n# Key Concepts\n**Grid Tra...
1
0
['Array', 'Depth-First Search', 'Python3']
0
minimum-number-of-days-to-disconnect-island
Ruby || DFS
ruby-dfs-by-alecn2002-w4en
\n# Code\nruby\nclass Grid\n include Enumerable\n\n attr_reader :grid, :h, :w, :hr, :wr\n\n def initialize(grid)\n @grid, @h, @w = grid, grid.si
alecn2002
NORMAL
2024-08-11T11:26:14.342906+00:00
2024-08-11T11:26:14.342931+00:00
10
false
\n# Code\n```ruby\nclass Grid\n include Enumerable\n\n attr_reader :grid, :h, :w, :hr, :wr\n\n def initialize(grid)\n @grid, @h, @w = grid, grid.size, grid.first.size\n @hr, @wr = (0...h), (0...w)\n end\n\n def each\n grid.each_with_index {|row, ridx|\n row.each_with_index...
1
0
['Ruby']
0
minimum-number-of-days-to-disconnect-island
easy||c++||only BFS||graph||beginner friendly||striver||
easyconly-bfsgraphbeginner-friendlystriv-j7u8
Intuition\n Describe your first thoughts on how to solve this problem. \nyou need to get no of island problem before doing it;\nthat qsn is the prerequisite of
sidvi
NORMAL
2024-08-11T10:46:17.670567+00:00
2024-08-11T10:46:17.670597+00:00
23
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nyou need to get no of island problem before doing it;\nthat qsn is the prerequisite of this problem\n\nlink:- https://leetcode.com/problems/number-of-islands/description/\nsolution to prerequisite problem:- https://leetcode.com/problems/n...
1
0
['Array', 'Breadth-First Search', 'Matrix', 'Strongly Connected Component', 'C++']
0
minimum-number-of-days-to-disconnect-island
C++ | Max 2 Removal
c-max-2-removal-by-sarvesh225-odq7
Approach\n Describe your approach to solving the problem. \nIf there are more than 1 disconnected islands return 0.\nIf all the elements of grid are 0 return 0.
sarvesh225
NORMAL
2024-08-11T10:32:59.475509+00:00
2024-08-11T10:35:14.494387+00:00
3
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nIf there are more than 1 disconnected islands return 0.\nIf all the elements of grid are 0 return 0.\nOne by one change the elements of the islands to 0, one at a time and check if any conversion disconnects the island. If it does return 1, else retur...
1
0
['C++']
0
minimum-number-of-days-to-disconnect-island
Simple Approach Beats 78.74% in time and 97.99% in space🔥🔥
simple-approach-beats-7874-in-time-and-9-4n0r
Intuition\nSimple bombing approach grid to get the number of islands\n Describe your first thoughts on how to solve this problem. \n\n\n# Approach\n1)If number
pranjalkishor5
NORMAL
2024-08-11T09:15:15.717545+00:00
2024-08-11T09:15:15.717580+00:00
6
false
# Intuition\nSimple bombing approach grid to get the number of islands\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/92f76577-7930-462d-89f5-c289c2a405c3_1723367689.501962.png)\n\n# Approach\n1)If number of islands is not one return 0.\n2)Try...
1
0
['C++']
0
minimum-number-of-days-to-disconnect-island
Simple BFS ✏️✏️✏️ | Python3 🔥🔥🔥
simple-bfs-python3-by-lightning_mc_queen-54qv
Complexity\n- Time complexity: O(MN)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(MN)\n Add your space complexity here, e.g. O(n) \n\n#
Lightning_Mc_Queen
NORMAL
2024-08-11T08:30:40.890867+00:00
2024-08-11T08:30:40.890907+00:00
10
false
# Complexity\n- Time complexity: $$O(M*N)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(M*N)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def minDays(self, grid: List[List[int]]) -> int:\n m, n = len(grid), len(grid[0])\n ...
1
0
['Breadth-First Search', 'Matrix', 'Python3']
0
minimum-number-of-days-to-disconnect-island
Interview Solution || Easy to Understand || Most Optimized
interview-solution-easy-to-understand-mo-81s4
\n\n# Complexity\n- Time complexity: O (n * m)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O (n * m)\n Add your space complexity here, e.
muntajir
NORMAL
2024-08-11T08:07:08.202912+00:00
2024-08-11T08:07:08.202937+00:00
109
false
\n\n# Complexity\n- Time complexity: O (n * m)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O (n * m)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n private final int[] delRow= {1,-1,0,0};\n private final int[] delCol= {0,0,-1,1};\n pr...
1
0
['Depth-First Search', 'Matrix', 'Strongly Connected Component', 'Java']
2