Crazy Insaan!! you are great. The way you solve and boil down to a simple formula and make the question so so easy is so insan now i am fan of your hats off to you skills
Thanks for an amazing explanation. 1. when you showed how the first example will work in a grid by removing the stones from 1.12 onwards, you are removing in the same order as if you remove the leaves from its spanning tree. how to actually go there? if we remove randomly matching stones, it wont end up with just 1 stone. 2. why the worst case complexity of naive solution is O(n2logn) if the amortized complexity of union-find is a constant: shouldn't the complexity be O(n2)? 3. what is the complexity of the final solution?
Your Explanations are just so great - To the point - No beating around the bush and extremely helpful. But you stopped making videos :( More power to you and may we find more such videos Admiration from India
I really enjoyed your explanation and the clean code you write, I am prepping for google interview next week, your channel came to me at the right time via leetcode discuss forum :) please keep making more videos
Thank you for your videos and content stumbled across this video looking for union find solution to this problem. I hope you continue to upload videos and content!
Thank you! Since it is also a union find question, it might take some time (i wanna do some tree, graph and recursion questions first) but seems interesting, thanks! ☺️
I have been going through all you videos in the list . Thanks for sharing all the knowledge . I couldn't understand how groups were created inside a constructor of union find , like in example 6 groups are created upfront . I understand union like maintain parent as : (item index , parent value) . But couldn't really visualize when item itself is combination of two numbers.
But I got it now , item is row and column individually and instead of indexing with array which we have generally use , we have a map also we don't care about stone but only its cordinates . Being from java background parent[col] gave me feeling of index instead of keys .
It was superb ..... can you suggest how to come up with such way of solving how you thought of this problem. Can you suggest some good resources to study for interviews
Thanks Aditya! I plan on doing a video with tips on how to approach such problems and maybe a series on data structures and common algorithms. For practicing I recommend LeetCode and GeeksforGeeks.
Awesome explanation !! Can you please tell what is the drawing tool that you use ? I was thinking of using some kind of drawing tool for my virtual interviews.
Thanks Ritwik! I like your suggestion, i will add this question to my list. I think the next one is going to be “robot room cleaner”. Hope you enjoy it :)
count will store the number of groups we have intially No, you can not do count = stones. size() this will be wrong just think over this example: [ [0, 0], [1,1], [2,2] ] here: count = stones. size() = 3 [WRONG] count = parent.size() = 6 [row0, col0, row1, col1 like that] [ CORRECT]
Thanks:) it’s not an error because you only care about the rank of the root (the representative of the set) and yset is now under xset so we only need to update the rank of xset
Yes, it is a difficult question. The idea is to try reducing the problem to something familiar. In this case - number of connected components in a graph.
Yes, it’s a difficult question. If you want to read up on union-find (Disjoint-set) data structure you can find a pretty detailed explanation on Wikipedia (en.wikipedia.org/wiki/Disjoint-set_data_structure ). You can also check out this Union-Find playlist from William Fiset ruclips.net/p/PLDV1Zeh2NRsBI1C-mR6ZhHTyfoEJWlxvq
Found your channel during my leetcode prep for interviews, super concise and clear explanations! Please keep uploading solutions!
Thanks Vince! I’m working on a new one. Hopefully will be up in a week or so.
Best channel to learn how to solve questions in competitive coding systematically.
Crazy Insaan!! you are great.
The way you solve and boil down to a simple formula and make the question so so easy is so insan now i am fan of your hats off to you skills
Thanks for an amazing explanation.
1. when you showed how the first example will work in a grid by removing the stones from 1.12 onwards, you are removing in the same order as if you remove the leaves from its spanning tree. how to actually go there? if we remove randomly matching stones, it wont end up with just 1 stone.
2. why the worst case complexity of naive solution is O(n2logn) if the amortized complexity of union-find is a constant: shouldn't the complexity be O(n2)?
3. what is the complexity of the final solution?
Amazing explanation. The diagram you used to explain made it really simple to understand.
Thanks! I’m glad it helped :)
Your Explanations are just so great - To the point - No beating around the bush and extremely helpful. But you stopped making videos :(
More power to you and may we find more such videos
Admiration from India
Thanks Aadarsh! I didn’t stop, I’ve been extra busy lately but will post more soon :)
I hope you are doing well. This is so great explanation! Keep Uploading and keep Shining!
@Shiran Afergan There is so much clarity in your explanation! Superb.
Thanks Jaideep! I’m glad you enjoyed it :)
Cheers from India. Looking forward to more such awesome content.
The way of explanation with visual effects is too good, Thanks for the video 😊
Very well explained Shiran!! Kudos!
I really enjoyed your explanation and the clean code you write, I am prepping for google interview next week, your channel came to me at the right time via leetcode discuss forum :) please keep making more videos
Working on it :) best of luck with your interview! 💪🏽
You are very Fluent and like the visualization Thanks for the hard work
Thanks 😊 glad you enjoyed it!
These videos deserve more views!
Thanks Senthil :)
Oh lord how I have struggled with this problem, where have you been
Haha glad it helped :)
Thank you for your videos and content stumbled across this video looking for union find solution to this problem. I hope you continue to upload videos and content!
Great explanation !! I really liked the way you explain the problem from scratch : ) Subscribed...
Thank you 🙏🏽:)
Astonish! thanks for your hard work
Amazing explanation ! Please keep making videos !
Thank you 😊 I’m working on it :)
Explanation is really awesome.
Thank you 🙏🏽 😊
Elegant solution. You have got a new subscriber :)
Thanks Akshay! I’m glad you liked it :)
Splendid Explanation !
Hey .. awesome explanation. Subscribed for easy explanation. Keep up the good work. Can you please do a videos on problem : region cut by slashes.
I am also looking for solution of this problem.
Thank you! Since it is also a union find question, it might take some time (i wanna do some tree, graph and recursion questions first) but seems interesting, thanks! ☺️
What an amazing explanation !!!!
🙏🏽🙂
Awesome plz continue series with Google questions
Thanks! I will :)
awesome explanation thank you.. keep making videos
Thanks:)
OMG ur very good at explaining
Thank you! I’m glad you liked it :)
Awesome video. How can you be so good at this? Keep posting please.
Thanks Jiadong! You just need to practice :)
Loved your explanation! thanks
Perfect explanantion !!
Thanks :)
Explained so well.
I have been going through all you videos in the list . Thanks for sharing all the knowledge .
I couldn't understand how groups were created inside a constructor of union find , like in example 6 groups are created upfront . I understand union like maintain parent as : (item index , parent value) . But couldn't really visualize when item itself is combination of two numbers.
But I got it now , item is row and column individually and instead of indexing with array which we have generally use , we have a map also we don't care about stone but only its cordinates . Being from java background parent[col] gave me feeling of index instead of keys .
I can see why it’s confusing:) I now code in Java in my job and I keep trying to use [] with maps and don’t understand why it’s not working 🙃
Thank you! Well explained.
It was superb ..... can you suggest how to come up with such way of solving how you thought of this problem. Can you suggest some good resources to study for interviews
Thanks Aditya! I plan on doing a video with tips on how to approach such problems and maybe a series on data structures and common algorithms.
For practicing I recommend LeetCode and GeeksforGeeks.
@@ShiranAfergan +1
great explanation! :)
Thanks :)
thank you, great explanation
Really nice explanation
Thanks :) glad you liked it.
Awesome explanation !! Can you please tell what is the drawing tool that you use ? I was thinking of using some kind of drawing tool for my virtual interviews.
It’s an iPad pro with GoodNotes
Hi, why have you added 1 to row and column.
Good explanation
Thanks 😊
can you make a video on this leetcode.com/problems/accounts-merge/ and can you more graph problems like this video. this video was very good. thanks
Thanks Ritwik! I like your suggestion, i will add this question to my list. I think the next one is going to be “robot room cleaner”. Hope you enjoy it :)
@@ShiranAfergan thanks a lot
It really helped ! Thanks a lot
You’re welcome :)
Why rank was not updated during merging in rest 2 conditions ?
great explanation
Thanks Javier!
Nice Explanation
Thanks :)
Welcome!!
I am unable to understand what does count variable stores initially, can we do count = stones. size(); as well
count will store the number of groups we have intially
No, you can not do count = stones. size() this will be wrong
just think over this example: [ [0, 0], [1,1], [2,2] ]
here:
count = stones. size() = 3 [WRONG]
count = parent.size() = 6 [row0, col0, row1, col1 like that] [ CORRECT]
amazing explanation, thanks a lot, I have a doubt- when rank[xset]
Thanks:) it’s not an error because you only care about the rank of the root (the representative of the set) and yset is now under xset so we only need to update the rank of xset
Watched that video again, and I was about to comment when I saw that I already did a year ago haha :P
Haha hope you enjoyed it the second time as well 😄
@@ShiranAfergan I did for sure :)
amazing! thank you
I’m glad you liked it :) thanks for watching.
You are beautiful ;) Btw Thanks for the explanation😊
Thanks and you’re welcome :) glad it helped
So max stones that can be removed = Total stones - no of connected components
Yup
ur the best
How do you even get those ideas ? I could have never thought of this problem in this manner.
Yes, it is a difficult question. The idea is to try reducing the problem to something familiar. In this case - number of connected components in a graph.
@@ShiranAfergan Thank your very much, Shiran !!
That's smart!!
Perfect. perfeect perfect peerrrfect
Glad you liked it 😆😊
@@ShiranAfergan can u plz plz increase frequency of uploading videos
union find? Amortzed what? Too difficult . I m not smart enough for this. Too hard. Where can I find a simple explanation of this ?
Yes, it’s a difficult question.
If you want to read up on union-find (Disjoint-set) data structure you can find a pretty detailed explanation on Wikipedia (en.wikipedia.org/wiki/Disjoint-set_data_structure ).
You can also check out this Union-Find playlist from William Fiset ruclips.net/p/PLDV1Zeh2NRsBI1C-mR6ZhHTyfoEJWlxvq
thankuhh :) -/\-
i came up with solution within 3 min of this video. good at explaining different test cases. curious to know your instagram id 😍
Awesome :) thanks for watching. I don’t have an active instagram account.
babe
great explanation
Thank you :)