Amazon Coding Interview Question - Clone Graph (LeetCode)

  Рет қаралды 33,960

AlgosWithMichael

AlgosWithMichael

Күн бұрын

Пікірлер: 69
@alexshay7969
@alexshay7969 Жыл бұрын
Hi Michael, I'm new to graph and your explanation is great to understand and a great DFS solution. Thank you!!
@sunnilabeouf
@sunnilabeouf 4 жыл бұрын
Great to see the whiteboarding and intuition behind the problem, would love to see more videos like these!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you, I plan to do alot more!
@saurabhdhamnaskar1737
@saurabhdhamnaskar1737 3 жыл бұрын
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
@anvithakaranam1033
@anvithakaranam1033 3 жыл бұрын
Love your content. the best explanation anyone could get. I wish you uploaded more frequently :)
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Yea, I will try to upload more. Full time job gets in the way of my upload schedule
@vidyasindhudubey5807
@vidyasindhudubey5807 2 жыл бұрын
Thank you soo much brother, your detailed explanation helped me a lot. Your really explained it very well. loved your content.
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
You are most welcome
@lapujain
@lapujain 4 жыл бұрын
Amazing problem solving skills. Keep up the good work dude. Liked, subscribed (cant miss another concept :P)
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Awesome, thank you!
@RahulVerma-fz2jf
@RahulVerma-fz2jf 4 жыл бұрын
Really good. Understood the question and solution really well.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Glad to hear, thanks so much for watching!
@Prashantkumar-pn6qq
@Prashantkumar-pn6qq 4 жыл бұрын
Very nice explanation. Simple and effective!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Glad it was helpful!
@pl5778
@pl5778 4 жыл бұрын
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.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
That is a great critique, I can do that in future videos. Thank you!
@ZhouHaibo
@ZhouHaibo 3 жыл бұрын
Great video, clear diagram and explanation.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad it was helpful!
@Jan_Jan_
@Jan_Jan_ 9 ай бұрын
Great explanation! 👍
@EchoVids2u
@EchoVids2u 4 жыл бұрын
Best Explanation on KZbin
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Wow, thanks!
@victorochoa2111
@victorochoa2111 4 жыл бұрын
AWESOME explanation. Thank you!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
You're very welcome!
@stackdev-io
@stackdev-io 4 жыл бұрын
great work, keep the good work up
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thank you so much for watching!
@surajkiranreddymothe686
@surajkiranreddymothe686 4 жыл бұрын
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)
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
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.
@surajkiranreddymothe686
@surajkiranreddymothe686 4 жыл бұрын
@@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).
@raymondtan2795
@raymondtan2795 3 жыл бұрын
@@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?
@tarlanabdullayev8980
@tarlanabdullayev8980 3 жыл бұрын
@@raymondtan2795 That makes sense. I have been thinking about that. it seems like it should be O(V * (V-1)) => O(V^2)
@mettudheeraj1393
@mettudheeraj1393 4 жыл бұрын
can u give me the recursion tree for the code as i have hard time understanding the above recursion?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
If you look up any DFS animation online, that would be the equivalent (since this problem is just doing DFS).
@mettudheeraj1393
@mettudheeraj1393 4 жыл бұрын
@@AlgosWithMichael thanks mate
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Anytime!
@thecheekychinaman6713
@thecheekychinaman6713 4 жыл бұрын
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?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
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.
@supremoluminary
@supremoluminary 4 жыл бұрын
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?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
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.
@numseidizer
@numseidizer 3 жыл бұрын
And the index (index + 1) is the val attribute.
@MeetManga
@MeetManga 2 жыл бұрын
Is the time complexity wrong? should be O(V+E) ?
@youmadvids
@youmadvids 2 жыл бұрын
great description
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Thanks!
@bharathkalyans
@bharathkalyans 2 жыл бұрын
Loved it 🙌
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Thank you!
@code7434
@code7434 4 жыл бұрын
Hi , please cover cherry pickup leetcode , u will love the que after reading
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I'll check it out!
@NareshKumar-dw9xp
@NareshKumar-dw9xp 4 жыл бұрын
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 :)
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Very true, good point. Thanks for watching and commenting!
@NareshKumar-dw9xp
@NareshKumar-dw9xp 4 жыл бұрын
@@AlgosWithMichael always welcome sir 💫❣️
@azfa3605
@azfa3605 3 жыл бұрын
Time Complexity should be O(V + E)
@EDROCKSWOO
@EDROCKSWOO 4 жыл бұрын
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.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Good feedback, I appreciate it. And thank you, I try haha
@rohitranjan2767
@rohitranjan2767 4 жыл бұрын
what to do in case of duplicate value nodes?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
For this problem, we can always assume the node values will be unique.
@AD-fs6hr
@AD-fs6hr 4 жыл бұрын
Nice Video. Suggestions : Can reduce video length, dont use language specific keywords.
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
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!
@testingDhippiuh
@testingDhippiuh 4 жыл бұрын
Thanks for sharing
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thanks for watching!
@shaileshhegde9205
@shaileshhegde9205 4 жыл бұрын
So the map is basically used for memoization
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Yea, pretty much!
@shaileshhegde9205
@shaileshhegde9205 4 жыл бұрын
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 :)
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
That is awesome, I hope it worked out for you!
@jagrit07
@jagrit07 4 жыл бұрын
Thanks for video, What does 1 prime 2 prime means ?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
It's more of just a way to denote the original and cloned. Thanks for watching!
@dineshteja8092
@dineshteja8092 4 жыл бұрын
bro,can u make a vide on bipartite graph ?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Yea, I'll add it to the list
@rahuldabas8233
@rahuldabas8233 4 жыл бұрын
you gained a sub.....: )
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Sick, thanks!
@in_tyler_we_trust
@in_tyler_we_trust 2 жыл бұрын
🧠💀
Hardest Coding Problem Explained (LeetCode)
16:47
AlgosWithMichael
Рет қаралды 11 М.
Clone Graph - Depth First Search - Leetcode 133
11:48
NeetCode
Рет қаралды 239 М.
Hilarious FAKE TONGUE Prank by WEDNESDAY😏🖤
0:39
La La Life Shorts
Рет қаралды 44 МЛН
Air Sigma Girl #sigma
0:32
Jin and Hattie
Рет қаралды 45 МЛН
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
Amazon Coding Interview Question - Min Stack (LeetCode)
8:34
AlgosWithMichael
Рет қаралды 7 М.
Clone Graph - Leetcode 133 - Graphs (Python)
13:38
Greg Hogg
Рет қаралды 4,8 М.
Spiral Matrix
10:16
Kevin Naughton Jr.
Рет қаралды 45 М.
Coding Interview Prep | 3 MUST KNOW Graph Problem Tips
13:27
AlgosWithMichael
Рет қаралды 18 М.
Clone graph | Leetcode #133
13:01
Techdose
Рет қаралды 59 М.
CLONE GRAPH | LEETCODE # 133 | PYTHON BFS SOLUTION
9:28
Cracking FAANG
Рет қаралды 3,4 М.
Solving Meta's 2024 Most Asked Interview Question
13:45
AlgosWithMichael
Рет қаралды 3 М.
FACEBOOK CODING INTERVIEW QUESTION - LOWEST COMMON ANCESTOR
10:22
AlgosWithMichael
Рет қаралды 9 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 684 М.
Climbing Stairs
5:35
Kevin Naughton Jr.
Рет қаралды 100 М.
Hilarious FAKE TONGUE Prank by WEDNESDAY😏🖤
0:39
La La Life Shorts
Рет қаралды 44 МЛН