Minimum Number of Days to Disconnect Island | Studied Concept | Leetcode 1568 | codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=HCHpyAk1Ekw



Duration: 0:00
10,878 views
594


Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 103rd Video of our Playlist "Array 1D/2D : Popular Interview Problems" by codestorywithMIK

In this video we will try to solve a simple 2D Array Problem : Minimum Number of Days to Disconnect Island | Already Studied Concept | Easy Code | Leetcode 1568 | codestorywithMIK

This can be more efficiently solved using "Tarjan's Algorithm". I will soon make a video on Tarjan and will then make a video for this problem using Tarjan.

I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : Minimum Number of Days to Disconnect Island | Already Studied Concept | Easy Code | Leetcode 1568 | codestorywithMIK
Company Tags : will update soon
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/minimum...


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | ...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram :   / codestorywithmik  
Facebook :   / 100090524295846  
Twitter :   / cswithmik  
Subscribe to my channel :    / @codestorywithmik  

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

Summary :
The approach above uses Depth-First Search (DFS) to determine the minimum number of days required to disconnect all land cells (represented by 1s) in a grid. The problem is treated as finding the number of "islands" in the grid, where an island is defined as a group of connected land cells.

Steps:

DFS Implementation:

The DFS function explores all connected land cells starting from any unvisited cell. It marks cells as visited to avoid reprocessing.
Counting Islands:

The numberOfIslandsDFS function uses DFS to count the number of islands in the grid. This is done by iterating through all cells in the grid and initiating a DFS whenever an unvisited land cell is found.
Determining Minimum Days:

Initially, the function checks if the grid is already disconnected (i.e., has more than one island or no islands). If so, the answer is 0 days.
If the grid is still connected, the function then checks whether removing a single land cell can disconnect the grid. If a single removal causes disconnection, the answer is 1 day.
If neither of the above conditions is met, the grid can always be disconnected in 2 days by removing two cells.
This approach efficiently determines the minimum number of days required by leveraging DFS for island detection and simulating cell removal.


✨ Timelines✨
00:00 - Introduction


#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #newyear2024




Other Videos By codestorywithMIK


2024-08-22DSA Shorts with MIK - 1
2024-08-22Number Complement | Multiple Approaches | Leetcode 476 | codestorywithMIK
2024-08-192 Keys Keyboard | Detailed Explanations | Leetcode 650 | codestorywithMIK
2024-08-18Count Substrings That Satisfy K-Constraint I & II | Detailed Explanation | Leetcode 3258 & 3261
2024-08-16Maximum Number of Points with Cost | Detailed Explanation | Leetcode 1937 | codestorywithMIK
2024-08-16The Imperial Delhi | Weekend Getaway | Luxury Stay | 5 Star hotel | WeekendWithMik
2024-08-15Maximum Distance in Arrays | Leetcode 624 | codestorywithMIK
2024-08-13Lemonade Change | Leetcode 860 | codestorywithMIK
2024-08-12Find K-th Smallest Pair Distance | Multiple Approaches | Leetcode 719 | codestorywithMIK
2024-08-11Combination Sum II | Simple Khandani Template | Leetcode 40 | codestorywithMIK
2024-08-09Minimum Number of Days to Disconnect Island | Studied Concept | Leetcode 1568 | codestorywithMIK
2024-08-08Magic Squares In Grid | Simple Approach | Clean Code | Leetcode 840 | codestorywithMIK
2024-08-08Thank you 60,000 Subscribers ❤️
2024-08-06Spiral Matrix III | Simple Simulation | Made Easy | Leetcode 885 | codestorywithMIK
2024-08-05Integer to English Words | Story To Code | Leetcode 273 | codestorywithMIK
2024-08-03Happy Friendship Day ❤️
2024-08-03Range Sum of Sorted Subarray Sums | Learning Something New | Leetcode 1508 | codestorywithMIK
2024-08-01Make Two Arrays Equal by Reversing Subarrays | Easy | Leetcode 1460 | codestorywithMIK
2024-07-31Minimum Swaps to Group All 1's Together II | 2 Ways | Dry Runs | Leetcode 2134 | codestorywithMIK
2024-07-29Filling Bookcase Shelves | Recursion Memoization | Why not Greedy | Leetcode 1105 | codestorywithMIK
2024-07-28Minimum Deletions to Make String Balanced | Multiple Approaches | Leetcode 1653 | codestorywithMIK