G-50. Accounts Merge - DSU

Поділитися
Вставка
  • Опубліковано 10 січ 2025

КОМЕНТАРІ • 217

  • @takeUforward
    @takeUforward  2 роки тому +39

    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

  • @kritikarawat2180
    @kritikarawat2180 Рік тому +85

    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.

  • @rishabhgupta9846
    @rishabhgupta9846 2 роки тому +60

    understood ,but for this solution even after knowing it is a DSU question such implementation is tough

  • @shivamandfriendsreact4089
    @shivamandfriendsreact4089 2 місяці тому +5

    brooooo what ? !!!!! even neetcode couldn't explain this as good as you did. kudos man !!!

  • @vishious14
    @vishious14 Рік тому +11

    The best explanation. I was able to code it on my own as soon as you explained the approach.

  • @arjundutta1515
    @arjundutta1515 7 місяців тому +5

    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....

  • @1tav0
    @1tav0 Рік тому +13

    this problem was awesome for my brain. Thank u so much for making it so clear striver understood

  • @yashshukla1637
    @yashshukla1637 20 днів тому +3

    Finally finished 50 questions at this point. 10 days before my google interview

    • @vinayakk2745
      @vinayakk2745 16 днів тому

      pleaaase let use know how it went! 🙏

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 2 роки тому +7

    watched it twice!! but now understood it

  • @harshalyallewar
    @harshalyallewar 4 місяці тому

    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.

  • @LBK3
    @LBK3 Рік тому +6

    Understood ❤
    the intuition has been explained excellently

  • @aruna5869
    @aruna5869 Рік тому +4

    understood. you are brilliant in finding suitable examples to make us understood❤

  • @lakshsinghania
    @lakshsinghania Рік тому +3

    understood! with such a clarity.
    was not able to figure it out whether its DSU qs or not

  • @beinghappy9223
    @beinghappy9223 Рік тому +11

    Hell of a code . Amazing explanation

  • @Moch117
    @Moch117 Рік тому +2

    Thanks Striver. This problem is hard af even if you know its DSU

  • @uknowme48
    @uknowme48 2 роки тому +2

    "US" BHAIYA .....whenever the heart is broken....video dekh dekh kr song yaad ho gya hai

  • @mmbmmbmmb
    @mmbmmbmmb Рік тому

    GOATED dsa mentor/teacher. Understood.

  • @manishkarmakar3927
    @manishkarmakar3927 Рік тому

    The way you explained the problem is simply mind blowing.... thanks bhaiyaa 💌

  • @cinime
    @cinime 2 роки тому +4

    Understood! Super amazing explanation as always, thank you very much!!

  • @Chandraprakash-kx4ic
    @Chandraprakash-kx4ic Рік тому +1

    This series is Totally dope.. Thank You Striver.. ok ok forgot to write.. "UNDERSTOOD"

  • @p38_amankuldeep75
    @p38_amankuldeep75 2 роки тому +7

    understood💙💙💙
    just enjoying this amazing graph series
    superb explanation ❤

  • @Sahil1001
    @Sahil1001 Рік тому +1

    its a tough one for sure but understood ur explaination , i need some time to digest it though

  • @devIOyu
    @devIOyu 4 місяці тому

    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

  • @SumitKeshariMCS
    @SumitKeshariMCS 2 роки тому +1

    Understood!!
    For this particular video, need to revise

  • @amanbhadani8840
    @amanbhadani8840 2 роки тому

    Ye new and unique question tha bhaiya, understood.

  • @sarankumaar6009
    @sarankumaar6009 Рік тому

    understood. I solved it on my own just bcoz of ur awsome disjoint explanation video :)

  • @Rajat_maurya
    @Rajat_maurya 2 роки тому +18

    understood
    no way i am going to guess this is a DSU question without prior practice

  • @Gamerz-g4i
    @Gamerz-g4i 11 днів тому

    Thank u so much for making it so clear striver understood

  • @Sumeet_100
    @Sumeet_100 Рік тому

    Thank You so much striver bhaiyya for this amazing Graph Series !!

  • @nirupamkumar6760
    @nirupamkumar6760 Рік тому

    Very good explanation, it makes life easy

  • @rushidesai2836
    @rushidesai2836 10 місяців тому

    On second rewatch, understood it better.

  • @shitizgoel5027
    @shitizgoel5027 Рік тому

    Very nice explanation bhaiya! Thanks

  • @stith_pragya
    @stith_pragya Рік тому +1

    Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @KUMARSAURABH-s5i
    @KUMARSAURABH-s5i 7 місяців тому

    brilliant explaination, thanks a lot striver

  • @adityaagarwal2324
    @adityaagarwal2324 2 роки тому +1

    Understood
    Awesome explanation 🔥

  • @sapna2019
    @sapna2019 2 роки тому +1

    Thanku striver for giving such a great content.

  • @yashshukla1637
    @yashshukla1637 20 днів тому

    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.

    • @aryanraj-t3r
      @aryanraj-t3r День тому

      can u share ur code with that logic?

  • @iamnoob7593
    @iamnoob7593 Рік тому

    Brilliant Explanation

  • @muditkhanna8164
    @muditkhanna8164 Рік тому

    Disjoint set does these merging things pretty easy.

  • @factsworlda2k547
    @factsworlda2k547 10 місяців тому

    you are amazing Striver 🙌🙌

  • @vanshpipaliya3217
    @vanshpipaliya3217 2 місяці тому

    Using hashmap also this problem done 🤯

  • @mathy642
    @mathy642 Рік тому

    Hey Striver
    Thank you for such wonderful explanation!!!:)

  • @MadhavGupta-fi2tu
    @MadhavGupta-fi2tu Рік тому +1

    They made it hard after strivers video

  • @paragroy5359
    @paragroy5359 10 місяців тому

    Thanks a lot.
    Nice video keep on making such videos.
    Awesome Content!!

  • @shivanshumishra0560
    @shivanshumishra0560 Рік тому

    Awesome explanation bhaiya 🔥

  • @shubhamkumar3198
    @shubhamkumar3198 Рік тому

    awesome explanation Understood sir

  • @r_uhi05
    @r_uhi05 9 місяців тому

    understood! Great explanation.

  • @kshitijmishra2716
    @kshitijmishra2716 2 роки тому

    understood maja aaa gya 😎😎🔥🔥

  • @SunnyKumar-dw9ze
    @SunnyKumar-dw9ze Рік тому

    Amazing explanation

  • @ayushman_sr
    @ayushman_sr 7 місяців тому

    GFG doesn't take output in any order but Leetcode does, bug is there in GFG for this problem. I coded in python

  • @onlysparsh
    @onlysparsh Рік тому

    Great explanation sir

  • @steverogers1657
    @steverogers1657 Рік тому +1

    inspiration for tier 3 college students

  • @sunilpanchal1498
    @sunilpanchal1498 Рік тому

    Great explanation 🔥

  • @PradneyaPrabhudesai
    @PradneyaPrabhudesai 4 місяці тому

    This is a tough question to crack..

  • @suryasingh2563
    @suryasingh2563 Рік тому

    understood bhaiya❣

  • @Xp-Sam
    @Xp-Sam 10 місяців тому +1

    The problem is , If it wasn't mentioned DSU anywhere, I wouldn't have thought anything apart from maps and sets.

  • @adebisisheriff159
    @adebisisheriff159 11 місяців тому

    Thanks so much striver!!!!

  • @abhishek__anand__
    @abhishek__anand__ Рік тому

    Great Explanation

  • @ApnaVlogs-tj7do
    @ApnaVlogs-tj7do Рік тому +1

    How can we come up to this type of solution of our own.

  • @madhavgaur7096
    @madhavgaur7096 2 місяці тому

    lol.. I was thinking in same way before seeing video ..but not confident...

  • @valarmorghulis9244
    @valarmorghulis9244 Рік тому

    It was HARD until Striver explaination

  • @PrajwalKakade
    @PrajwalKakade 2 роки тому +11

    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());

  • @shauryatomer1058
    @shauryatomer1058 4 місяці тому

    thanks for the great content

  • @MCA_HimanshuSeth
    @MCA_HimanshuSeth Рік тому

    very nice explantion sir

  • @UECAshutoshKumar
    @UECAshutoshKumar Рік тому +1

    Thank you sir 😊

  • @HeenaAhmed-e2l
    @HeenaAhmed-e2l 17 днів тому

    is it possible to do it using merge sort like algo ?

  • @World-Of-Mr-Motivater
    @World-Of-Mr-Motivater 7 місяців тому +1

    striver since the map(incase of ordered map) already stores the mails in the sorted order
    is sorting the mail is neccessary?

    • @divyanshmishra5121
      @divyanshmishra5121 4 місяці тому

      ordered map stores the keys in sorted order, not the values of the keys

  • @gautamsaxena4647
    @gautamsaxena4647 4 місяці тому

    understood bhaiya

  • @averylazyandweirdhuman
    @averylazyandweirdhuman 7 місяців тому

    Striver why don't we directly set the ultimate parent in the hashmap itself?

  • @shivarajput9719
    @shivarajput9719 11 місяців тому

    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

    • @ZAP-25
      @ZAP-25 4 місяці тому

      Different people can not have same mail.

  • @parshchoradia9909
    @parshchoradia9909 Рік тому

    Understood Sir!

  • @krishanpratap3286
    @krishanpratap3286 2 роки тому +1

    isme instead of vectormergeMail[n] hum 2d vector of string le sakte hein kya?

    • @itsaryanb9316
      @itsaryanb9316 2 роки тому

      same question

    • @yt_deepx
      @yt_deepx 2 роки тому +2

      yes you can, in that case you' ll use it as vector mergeMail(n);

    • @lakshsinghania
      @lakshsinghania Рік тому

      yeah he is using array of vectors , u can use vector of vector in place of that

  • @after_dark_777
    @after_dark_777 8 місяців тому

    how does this code handle repeating mails?

  • @a2_63_vimalmishra9
    @a2_63_vimalmishra9 2 роки тому +1

    why i am getting wa at 56 in gfg

  • @SwethaSrirangam
    @SwethaSrirangam 5 місяців тому +3

    actually i didnt find any diff between tuf and tuf++

  • @suryakiran2970
    @suryakiran2970 Рік тому

    Understood❤

  • @shaliniguptaietlucknow2301
    @shaliniguptaietlucknow2301 2 роки тому

    Thanks by heart

  • @japkiratsingh3728
    @japkiratsingh3728 Рік тому

    understood💖💖

  • @priyankkumawat4405
    @priyankkumawat4405 Рік тому

    I have subscribed bro

  • @vigneshreddy1213
    @vigneshreddy1213 8 місяців тому

    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;

    • @vigneshreddy1213
      @vigneshreddy1213 8 місяців тому

      And The Issue was resolved by the gfg customer care they increased time limit for the problem. Any way thankyou for this content

  • @umakarthikrayudu5760
    @umakarthikrayudu5760 Рік тому +3

    At 16:31 , I think its ds.unionBySize(mapMailNode[mail],i);

  • @ACUCSPRADEEPB-up9ne
    @ACUCSPRADEEPB-up9ne 2 роки тому

    Understood✌️

  • @AMANZAKIRHUSAINMODAN
    @AMANZAKIRHUSAINMODAN 6 місяців тому

    I cant solve it w/o seeing soln is it okay and normal ?

  • @mmmm-wm8ci
    @mmmm-wm8ci 2 роки тому +1

    Why can't we use parent array directly for finding parent instead of using findUpar function

    • @piyushacharya7696
      @piyushacharya7696 2 роки тому

      we can use it too!

    • @mmmm-wm8ci
      @mmmm-wm8ci 2 роки тому

      @@piyushacharya7696 ans will not be same did u check

    • @yt_deepx
      @yt_deepx 2 роки тому +6

      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.

    • @nirutgupta5894
      @nirutgupta5894 2 роки тому

      @D E E P is correct there is a difference between par and the ultimatepar and we need to find the ultimatepar here.

    • @mmmm-wm8ci
      @mmmm-wm8ci 2 роки тому

      @@yt_deepx but we are filling par array using findUltimateParent func

  • @vishalbairagi5364
    @vishalbairagi5364 5 місяців тому

    submit the solution to problem named accounts merge, merging details has some problem with test case 3 and test case 56

  • @santhoshreddy2603
    @santhoshreddy2603 8 місяців тому

    bro i can solve dsa based problem only if i know the topics they belong(identifying the qn),bro how can i overcome this

  • @NiteshKumar-xm3nq
    @NiteshKumar-xm3nq 5 місяців тому

    do you uses mouse ?

  • @prajjwalgurjar3887
    @prajjwalgurjar3887 Рік тому

    understood🙌

  • @herculean6748
    @herculean6748 Рік тому

    Thanks🙌

  • @shreyarawatvlogs6920
    @shreyarawatvlogs6920 11 місяців тому

    it is showing runtime error

  • @manasranjanmahapatra3729
    @manasranjanmahapatra3729 Рік тому

    Understood.

  • @RituSingh-ne1mk
    @RituSingh-ne1mk 11 місяців тому

    Understood!

  • @omop5922
    @omop5922 Рік тому

    Is this doable in an interview

  • @aryankumar3018
    @aryankumar3018 Рік тому

    Understoood R

  • @shivarajput9719
    @shivarajput9719 11 місяців тому

    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

  • @rounakmukherjee9540
    @rounakmukherjee9540 2 роки тому

    UNDERSTOOD

  • @sohammukherjee1392
    @sohammukherjee1392 Рік тому

    Time complexity??

  • @AMANZAKIRHUSAINMODAN
    @AMANZAKIRHUSAINMODAN 6 місяців тому

    Just think for a moment you did not open this quen w/o learning graphs ! Were you able to solve this ??????

  • @vatsalvasoya5243
    @vatsalvasoya5243 Рік тому

    Understood!!

  • @tiyaroy4714
    @tiyaroy4714 5 місяців тому

    understood!!!