Amazon Coding Interview Question - Clone Graph (LeetCode)

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

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 2 жыл бұрын
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
@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!
@EchoVids2u
@EchoVids2u 4 жыл бұрын
Best Explanation on KZbin
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Wow, thanks!
@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.
@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
@Prashantkumar-pn6qq
@Prashantkumar-pn6qq 4 жыл бұрын
Very nice explanation. Simple and effective!
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Glad it was helpful!
@ZhouHaibo
@ZhouHaibo 3 жыл бұрын
Great video, clear diagram and explanation.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad it was helpful!
@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!
@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
@Jan_Jan_
@Jan_Jan_ 7 ай бұрын
Great explanation! 👍
@code7434
@code7434 4 жыл бұрын
Hi , please cover cherry pickup leetcode , u will love the que after reading
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
I'll check it out!
@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
@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)
@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!
@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!
@MeetManga
@MeetManga 2 жыл бұрын
Is the time complexity wrong? should be O(V+E) ?
@youmadvids
@youmadvids 2 жыл бұрын
great description
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Thanks!
@supremoluminary
@supremoluminary 3 жыл бұрын
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 3 жыл бұрын
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.
@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!
@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 💫❣️
@bharathkalyans
@bharathkalyans 2 жыл бұрын
Loved it 🙌
@AlgosWithMichael
@AlgosWithMichael 2 жыл бұрын
Thank you!
@azfa3605
@azfa3605 3 жыл бұрын
Time Complexity should be O(V + E)
@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!
@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!
@dineshteja8092
@dineshteja8092 4 жыл бұрын
bro,can u make a vide on bipartite graph ?
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Yea, I'll add it to the list
@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!
@testingDhippiuh
@testingDhippiuh 4 жыл бұрын
Thanks for sharing
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Thanks for watching!
@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.
@rahuldabas8233
@rahuldabas8233 4 жыл бұрын
you gained a sub.....: )
@AlgosWithMichael
@AlgosWithMichael 4 жыл бұрын
Sick, thanks!
@in_tyler_we_trust
@in_tyler_we_trust 2 жыл бұрын
🧠💀
Coding Interview Prep | 3 MUST KNOW Graph Problem Tips
13:27
AlgosWithMichael
Рет қаралды 18 М.
Clone graph | Leetcode #133
13:01
Techdose
Рет қаралды 59 М.
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 92 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,6 МЛН
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 111 МЛН
Clone Graph - Leetcode 133 - Graphs (Python)
13:38
Greg Hogg
Рет қаралды 3,8 М.
Technical Interview Question: Number of Islands [LeetCode]
17:48
AlgosWithMichael
Рет қаралды 32 М.
Clone Graph - Depth First Search - Leetcode 133
11:48
NeetCode
Рет қаралды 230 М.
Amazon Coding Interview Question - Sum of Left Leaves (LeetCode)
16:17
AlgosWithMichael
Рет қаралды 4,6 М.
Solving Amazon's 2024 Most Asked Coding Question
18:09
AlgosWithMichael
Рет қаралды 4,5 М.
Graph Coding Question - All Paths From Source To Target (LeetCode)
12:39
AlgosWithMichael
Рет қаралды 39 М.
[Java] Leetcode 133. Clone Graph [Search #7]
12:56
Eric Programming
Рет қаралды 3,6 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 577 М.
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 92 МЛН