Making A Large Island | Leetcode 827 | Matrix Graph DFS Hard | Facebook Apple

  Рет қаралды 2,324

Naresh Gupta

Naresh Gupta

Күн бұрын

Пікірлер: 10
@AP-eh6gr
@AP-eh6gr Жыл бұрын
thank you for explaining!
@NareshGupta
@NareshGupta Жыл бұрын
You're welcome!
@praveenj3112
@praveenj3112 3 жыл бұрын
Thanks Naresh for the outstanding explanation. it really helped a lot .
@NareshGupta
@NareshGupta 3 жыл бұрын
Most welcome!
@mrprime557
@mrprime557 3 жыл бұрын
Why is the dimension on A array- n* n+2 ?? I didnt understand the n+2 part
@rahulmodi926
@rahulmodi926 3 жыл бұрын
Can you tell how time complexity in 1st approach is O(n4). And if it is O(n4) in 1st approach, how it is O(n2) in 2nd approach as DFS is used within matrix traversal in both approaches.
@NareshGupta
@NareshGupta 3 жыл бұрын
In first approach we are running two nested for loop and then applying dfs for each zero cells --> n^2 * n^2 = n^4 While in second approach we are first running simple dfs --> n^2 and storing and marking area colors of each island. Hope it clear ur doubt.
@Jay-lj2bv
@Jay-lj2bv 3 жыл бұрын
@@NareshGupta so the worst case is when all the cells of matrix are zero. so for each cell in dfs function it will look for one in adjacent cell (left,right,top,bottom)but since all the adjacent will be having zeroes it will retun 0; so don't you think time complexity should be n^2! Actually i know i am wrong but i just find it difficult to know time complexity can u correct me?
@rsroyalrahul5
@rsroyalrahul5 3 жыл бұрын
please dont use red color on black!!!
@NareshGupta
@NareshGupta 3 жыл бұрын
Thanks, noted.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 327 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Sorting Algorithms Explained Visually
9:01
Beyond Fireship
Рет қаралды 563 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 243 М.
Rotate Image - Matrix - Leetcode 48
15:46
NeetCode
Рет қаралды 254 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 680 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН