Regions Cut By Slashes | Already Studied Concept | Easy Code | Leetcode 959 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 102nd 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 : Regions Cut By Slashes | Already Studied Concept | Easy Code | Leetcode 959 | codestorywithMIK
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 : Regions Cut By Slashes | Already Studied Concept | Easy Code | Leetcode 959 | codestorywithMIK
Company Tags : GOOGLE
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/regions...
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 in this solution aims to count the number of distinct regions formed by slashes ('/' and '\') in a grid. The strategy involves:
Grid Expansion: Each cell in the original grid is expanded into a 3x3 sub-grid to handle the slashes more easily. A slash '/' is represented by marking a diagonal from the top-right to the bottom-left in the sub-grid, and a backslash '\' is represented by marking a diagonal from the top-left to the bottom-right.
Depth-First Search (DFS): The algorithm uses DFS to explore and mark connected regions of unmarked cells (0s) in the expanded grid. This is done by checking each cell, and if it is unmarked, the DFS marks it and recursively explores its neighboring cells in four possible directions (up, down, left, right).
Counting Regions: For every unmarked cell found in the expanded grid, the algorithm initiates a DFS to mark the entire connected region, and increments the region count.
Final Output: The total count of DFS operations corresponds to the number of distinct regions formed by the slashes in the original grid.
This approach effectively breaks down the problem into manageable components by expanding the grid and using DFS to explore and count regions.
✨ 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