Hi Michael, I'm new to graph and your explanation is great to understand and a great DFS solution. Thank you!!
@sunnilabeouf4 жыл бұрын
Great to see the whiteboarding and intuition behind the problem, would love to see more videos like these!
@AlgosWithMichael4 жыл бұрын
Thank you, I plan to do alot more!
@saurabhdhamnaskar17372 жыл бұрын
You explained the entire concept so easily. I would have saved my time if your video came up on the top on KZbin. Thanks brother
@pl57784 жыл бұрын
This is excellent, love the way you explain and show so intuitively. Would love for you to actually go through the code with the example line by line to completely drive home the implementation. Cheers.
@AlgosWithMichael4 жыл бұрын
That is a great critique, I can do that in future videos. Thank you!
@EchoVids2u4 жыл бұрын
Best Explanation on KZbin
@AlgosWithMichael4 жыл бұрын
Wow, thanks!
@thecheekychinaman67134 жыл бұрын
you're one of the few people working on graphs, and using a whiteboard. well appreciated and subbed. However, how does the code ensure that we always return the value 1 entry node?
@AlgosWithMichael4 жыл бұрын
Glad you enjoyed it, more to come! The reason we always return the value 1 node is because we start recursion off by passing in the initial value 1 node every time. In the description, it notes that node 1 will always be our input node to the function.
@vidyasindhudubey58072 жыл бұрын
Thank you soo much brother, your detailed explanation helped me a lot. Your really explained it very well. loved your content.
@AlgosWithMichael2 жыл бұрын
You are most welcome
@Prashantkumar-pn6qq4 жыл бұрын
Very nice explanation. Simple and effective!
@AlgosWithMichael4 жыл бұрын
Glad it was helpful!
@ZhouHaibo3 жыл бұрын
Great video, clear diagram and explanation.
@AlgosWithMichael3 жыл бұрын
Glad it was helpful!
@RahulVerma-fz2jf4 жыл бұрын
Really good. Understood the question and solution really well.
@AlgosWithMichael4 жыл бұрын
Glad to hear, thanks so much for watching!
@anvithakaranam10333 жыл бұрын
Love your content. the best explanation anyone could get. I wish you uploaded more frequently :)
@AlgosWithMichael3 жыл бұрын
Yea, I will try to upload more. Full time job gets in the way of my upload schedule
@Jan_Jan_7 ай бұрын
Great explanation! 👍
@code74344 жыл бұрын
Hi , please cover cherry pickup leetcode , u will love the que after reading
@AlgosWithMichael4 жыл бұрын
I'll check it out!
@EDROCKSWOO4 жыл бұрын
I think the ArrayList that you marked 2nd part dosen't actually enter until the recursion is finished. It is kind of confusing that you add the 2nd part after you create the map deeper search map. The arraylist map happens as the graph is finishing it's traversal and returns the "root". Overall still the best vid on youtube.
@AlgosWithMichael4 жыл бұрын
Good feedback, I appreciate it. And thank you, I try haha
@surajkiranreddymothe6864 жыл бұрын
Could you please explain why time complexity is O(N)? "When we are working on a node, we are touching all it's neighbors once" We do the process in quotes for all nodes. So shouldn't the time complexity be O(N*N)
@AlgosWithMichael4 жыл бұрын
It is O(N) because when we touch each neighbor of a given node, we are saving that node inside of our map (think of the map as a cache), thus when we go to that node again we do not have to make a copy again after saving it.
@surajkiranreddymothe6864 жыл бұрын
@@AlgosWithMichael Thanks, Michael. Now it makes sense. Basically, touching a neighbour which is already processed is O(1) operation. So it is O(N*1)=O(N).
@raymondtan27953 жыл бұрын
@@AlgosWithMichael Wait I still don't get it...even if touching a neighbor is a constant operation, couldn't we potentially be doing that E amount of times at each node, where E is the amount of edges in the graph? Like take a graph where every node is connected to every other node. Even when we get to the very last node where all of the new nodes have been created, don't we still have to loop through E amount of times? This would make the time complexity (E * V) (where V is the number of vertices in the graph), right?
@tarlanabdullayev89803 жыл бұрын
@@raymondtan2795 That makes sense. I have been thinking about that. it seems like it should be O(V * (V-1)) => O(V^2)
@victorochoa21114 жыл бұрын
AWESOME explanation. Thank you!
@AlgosWithMichael4 жыл бұрын
You're very welcome!
@stackdev-io4 жыл бұрын
great work, keep the good work up
@AlgosWithMichael4 жыл бұрын
Thank you so much for watching!
@lapujain4 жыл бұрын
Amazing problem solving skills. Keep up the good work dude. Liked, subscribed (cant miss another concept :P)
@AlgosWithMichael4 жыл бұрын
Awesome, thank you!
@MeetManga2 жыл бұрын
Is the time complexity wrong? should be O(V+E) ?
@youmadvids2 жыл бұрын
great description
@AlgosWithMichael2 жыл бұрын
Thanks!
@supremoluminary3 жыл бұрын
What is the data in the test data? You wrote your tutorial but how does that translate to e.g. Input: adjList = [[2,4],[1,3],[2,4],[1,3]]? If you could explain that, I might get it. My interpretation of that data is four rows, two columns. but that's not right. It doesn't match your diagrams of bubbles connected by lines. I don't get it. What is this array of arrays test data?
@AlgosWithMichael3 жыл бұрын
The index of the arrays are the connections. So for example, [[2, 4]] has only the 0 index. So 2 connections being 0 -> 2 and 0 -> 4.
@numseidizer3 жыл бұрын
And the index (index + 1) is the val attribute.
@AD-fs6hr4 жыл бұрын
Nice Video. Suggestions : Can reduce video length, dont use language specific keywords.
@AlgosWithMichael4 жыл бұрын
Yea, good points. I try my best to reduce the length of the videos, but they always seem to be longer than expected. Thanks for watching!
@NareshKumar-dw9xp4 жыл бұрын
I think it will not work when there is are self loops in the graph. Better to use Map instead of Map . Leetcode will accept your answer but Interview Bit will not :)
@AlgosWithMichael4 жыл бұрын
Very true, good point. Thanks for watching and commenting!
@NareshKumar-dw9xp4 жыл бұрын
@@AlgosWithMichael always welcome sir 💫❣️
@bharathkalyans2 жыл бұрын
Loved it 🙌
@AlgosWithMichael2 жыл бұрын
Thank you!
@azfa36053 жыл бұрын
Time Complexity should be O(V + E)
@mettudheeraj13934 жыл бұрын
can u give me the recursion tree for the code as i have hard time understanding the above recursion?
@AlgosWithMichael4 жыл бұрын
If you look up any DFS animation online, that would be the equivalent (since this problem is just doing DFS).
@mettudheeraj13934 жыл бұрын
@@AlgosWithMichael thanks mate
@AlgosWithMichael4 жыл бұрын
Anytime!
@shaileshhegde92054 жыл бұрын
So the map is basically used for memoization
@AlgosWithMichael4 жыл бұрын
Yea, pretty much!
@shaileshhegde92054 жыл бұрын
Michael Muinos this is helping me a lot!I just cleared my online assessment with amazon sde 1,hopefully will land a direct onsite ,your problems are nevertheless helping me,thank you :)
@AlgosWithMichael4 жыл бұрын
That is awesome, I hope it worked out for you!
@dineshteja80924 жыл бұрын
bro,can u make a vide on bipartite graph ?
@AlgosWithMichael4 жыл бұрын
Yea, I'll add it to the list
@jagrit074 жыл бұрын
Thanks for video, What does 1 prime 2 prime means ?
@AlgosWithMichael4 жыл бұрын
It's more of just a way to denote the original and cloned. Thanks for watching!
@testingDhippiuh4 жыл бұрын
Thanks for sharing
@AlgosWithMichael4 жыл бұрын
Thanks for watching!
@rohitranjan27674 жыл бұрын
what to do in case of duplicate value nodes?
@AlgosWithMichael4 жыл бұрын
For this problem, we can always assume the node values will be unique.