I've explored a lot of youtube videos to understand graph. No one can exaplain with such a clarity and concept. I was also able to do similar kind of problems after learning the pattern. Greate playlist....
00:06 Merging similar accounts based on name and email accounts 02:37 Merging accounts using disjoint set data structure. 05:05 Understanding disjoint sets and merging elements 07:45 Merging accounts in disjoint set data structure 10:17 Merging accounts based on parent-child relationships. 12:41 Using disjoint data structure to merge accounts efficiently 14:58 Creating disjoint sets and merging accounts 17:25 Merge accounts into ultimate parent and return list of lists 19:48 Explaining the process of merging accounts using disjoint set data structure. 21:45 Encouragement to remember you are valuable even when feeling broken-hearted.
Thanks took me 2 and half hours to complete the implementation of this problem but never looked at the solution. But just finding the approach would take me weeks , thanks for the solution
we could potentially skip the use of explicit node indices if we directly manage the mapping between emails and their parents in the DSU. Instead of associating each account with a numeric index, we can directly associate emails with their parent emails using DSU. This approach simplifies the code and avoids the extra step of mapping accounts to indices.
In the example you are saying 3 ka ultimate parent is 0, but if 0 index name is john and 3rd index name is ram then in the list it will store john -> all emails, ideally instead of john there will be ram. In the code it is showing correct because 0 ka ultimate parent is 3. @takeUforward
Hey Striver at Present the number of test cases were increased to 1151 then the intution you suggested suceeded till 400 change test cases can you make another video for avoidance of tle;
well, parent array will give you "its parent" not the actual Ultimate Parent if we not use findUPar, remember the first DSU lecture. we do findPar for getting that ult Par.
For instance, in the given input: john -> j1@com, j2@com, j3@com john -> j4@com raj -> r1@com, r2@com, r3@com john -> j1@com, j5@com raj -> r1@com, r3@com mary -> m1@com According to your explanation OUTPUT john -> j1@com, j2@com, j3@com, j4@com, j5@com raj -> 1@com, r2@com, r3@com mary -> m1@com But if the input is john -> j1@com, j2@com, j3@com john -> j4@com raj -> r1@com, r2@com, r3@com ram -> j1@com, j5@com raj -> r1@com, r3@com mary -> m1@com correct output is OUTPUT ram -> j1@com, j2@com, j3@com, j4@com, j5@com raj -> 1@com, r2@com, r3@com mary -> m1@com but according to your explanation, the output will be john -> j1@com, j2@com, j3@com, j4@com, j5@com raj -> 1@com, r2@com, r3@com mary -> m1@com because you are saying 3 ka ultimate parent is 0 but correct should be 0 ka ultimate parent 3
Let's continue the habit of commenting “understood” if you got the entire video. Please give it a like too,.
Do follow me on Instagram: striver_79
understood
I feel you are the best graph teacher bcz after watching graph videos in this channel i didnt looked at any other channel to understand any question.
understood ,but for this solution even after knowing it is a DSU question such implementation is tough
brooooo what ? !!!!! even neetcode couldn't explain this as good as you did. kudos man !!!
Agreee!!!
The best explanation. I was able to code it on my own as soon as you explained the approach.
I've explored a lot of youtube videos to understand graph. No one can exaplain with such a clarity and concept.
I was also able to do similar kind of problems after learning the pattern. Greate playlist....
this problem was awesome for my brain. Thank u so much for making it so clear striver understood
Finally finished 50 questions at this point. 10 days before my google interview
pleaaase let use know how it went! 🙏
watched it twice!! but now understood it
00:06 Merging similar accounts based on name and email accounts
02:37 Merging accounts using disjoint set data structure.
05:05 Understanding disjoint sets and merging elements
07:45 Merging accounts in disjoint set data structure
10:17 Merging accounts based on parent-child relationships.
12:41 Using disjoint data structure to merge accounts efficiently
14:58 Creating disjoint sets and merging accounts
17:25 Merge accounts into ultimate parent and return list of lists
19:48 Explaining the process of merging accounts using disjoint set data structure.
21:45 Encouragement to remember you are valuable even when feeling broken-hearted.
Understood ❤
the intuition has been explained excellently
understood. you are brilliant in finding suitable examples to make us understood❤
understood! with such a clarity.
was not able to figure it out whether its DSU qs or not
Hell of a code . Amazing explanation
Thanks Striver. This problem is hard af even if you know its DSU
"US" BHAIYA .....whenever the heart is broken....video dekh dekh kr song yaad ho gya hai
your*
GOATED dsa mentor/teacher. Understood.
The way you explained the problem is simply mind blowing.... thanks bhaiyaa 💌
Understood! Super amazing explanation as always, thank you very much!!
This series is Totally dope.. Thank You Striver.. ok ok forgot to write.. "UNDERSTOOD"
understood💙💙💙
just enjoying this amazing graph series
superb explanation ❤
its a tough one for sure but understood ur explaination , i need some time to digest it though
Thanks took me 2 and half hours to complete the implementation of this problem but never looked at the solution.
But just finding the approach would take me weeks , thanks for the solution
Understood!!
For this particular video, need to revise
Ye new and unique question tha bhaiya, understood.
understood. I solved it on my own just bcoz of ur awsome disjoint explanation video :)
understood
no way i am going to guess this is a DSU question without prior practice
Thank u so much for making it so clear striver understood
Thank You so much striver bhaiyya for this amazing Graph Series !!
Very good explanation, it makes life easy
On second rewatch, understood it better.
Very nice explanation bhaiya! Thanks
Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
brilliant explaination, thanks a lot striver
Understood
Awesome explanation 🔥
Thanku striver for giving such a great content.
we could potentially skip the use of explicit node indices if we directly manage the mapping between emails and their parents in the DSU. Instead of associating each account with a numeric index, we can directly associate emails with their parent emails using DSU. This approach simplifies the code and avoids the extra step of mapping accounts to indices.
can u share ur code with that logic?
Brilliant Explanation
Disjoint set does these merging things pretty easy.
you are amazing Striver 🙌🙌
Using hashmap also this problem done 🤯
Hey Striver
Thank you for such wonderful explanation!!!:)
They made it hard after strivers video
Thanks a lot.
Nice video keep on making such videos.
Awesome Content!!
Awesome explanation bhaiya 🔥
awesome explanation Understood sir
understood! Great explanation.
understood maja aaa gya 😎😎🔥🔥
Amazing explanation
GFG doesn't take output in any order but Leetcode does, bug is there in GFG for this problem. I coded in python
Great explanation sir
inspiration for tier 3 college students
Great explanation 🔥
This is a tough question to crack..
understood bhaiya❣
The problem is , If it wasn't mentioned DSU anywhere, I wouldn't have thought anything apart from maps and sets.
Thanks so much striver!!!!
Great Explanation
How can we come up to this type of solution of our own.
lol.. I was thinking in same way before seeing video ..but not confident...
It was HARD until Striver explaination
Those are getting WA on 56 on GFG, just sort the ans by adding this line before return statement.
sort(ans.begin(), ans.end(), greater());
Dhanyavaad
Bro, can you explain what is actually happening here????
@@ayushanand6957 sorting in descending order ig
What is the reason behind this extra greater function?
It gives wrong ans for some other test cases.
thanks for the great content
very nice explantion sir
Thank you sir 😊
is it possible to do it using merge sort like algo ?
striver since the map(incase of ordered map) already stores the mails in the sorted order
is sorting the mail is neccessary?
ordered map stores the keys in sorted order, not the values of the keys
understood bhaiya
Striver why don't we directly set the ultimate parent in the hashmap itself?
In the example you are saying 3 ka ultimate parent is 0, but if 0 index name is john and 3rd index name is ram then in the list it will store john -> all emails, ideally instead of john there will be ram. In the code it is showing correct because 0 ka ultimate parent is 3. @takeUforward
Different people can not have same mail.
Understood Sir!
isme instead of vectormergeMail[n] hum 2d vector of string le sakte hein kya?
same question
yes you can, in that case you' ll use it as vector mergeMail(n);
yeah he is using array of vectors , u can use vector of vector in place of that
how does this code handle repeating mails?
why i am getting wa at 56 in gfg
actually i didnt find any diff between tuf and tuf++
😂
andhuke nenu kuda tesukole
Understood❤
Thanks by heart
Understood!
understood💖💖
I have subscribed bro
Hey Striver at Present the number of test cases were increased to 1151 then the intution you suggested suceeded till 400 change test cases can you make another video for avoidance of tle;
And The Issue was resolved by the gfg customer care they increased time limit for the problem. Any way thankyou for this content
At 16:31 , I think its ds.unionBySize(mapMailNode[mail],i);
why does it matter?
You are correct it work in running the 3rd test case in gfg
Understood✌️
I cant solve it w/o seeing soln is it okay and normal ?
Why can't we use parent array directly for finding parent instead of using findUpar function
we can use it too!
@@piyushacharya7696 ans will not be same did u check
well, parent array will give you "its parent" not the actual Ultimate Parent if we not use findUPar, remember the first DSU lecture. we do findPar for getting that ult Par.
@D E E P is correct there is a difference between par and the ultimatepar and we need to find the ultimatepar here.
@@yt_deepx but we are filling par array using findUltimateParent func
submit the solution to problem named accounts merge, merging details has some problem with test case 3 and test case 56
bro i can solve dsa based problem only if i know the topics they belong(identifying the qn),bro how can i overcome this
do you uses mouse ?
understood🙌
Thanks🙌
it is showing runtime error
Understood.
Understood!
Is this doable in an interview
Understoood R
For instance, in the given input:
john -> j1@com, j2@com, j3@com
john -> j4@com
raj -> r1@com, r2@com, r3@com
john -> j1@com, j5@com
raj -> r1@com, r3@com
mary -> m1@com
According to your explanation
OUTPUT
john -> j1@com, j2@com, j3@com, j4@com, j5@com
raj -> 1@com, r2@com, r3@com
mary -> m1@com
But if the input is
john -> j1@com, j2@com, j3@com
john -> j4@com
raj -> r1@com, r2@com, r3@com
ram -> j1@com, j5@com
raj -> r1@com, r3@com
mary -> m1@com
correct output is
OUTPUT
ram -> j1@com, j2@com, j3@com, j4@com, j5@com
raj -> 1@com, r2@com, r3@com
mary -> m1@com
but according to your explanation, the output will be
john -> j1@com, j2@com, j3@com, j4@com, j5@com
raj -> 1@com, r2@com, r3@com
mary -> m1@com
because you are saying 3 ka ultimate parent is 0 but correct should be 0 ka ultimate parent 3
UNDERSTOOD
Time complexity??
Just think for a moment you did not open this quen w/o learning graphs ! Were you able to solve this ??????
Understood!!
understood!!!