Leetcode 1722. Minimize Hamming Distance After Swap Operations

DSU • DISJOINT SETS | Compet...
leetcode.com/problems/minimiz...
Connect with me on LinkedIn :- / mohammad-f-bb4886157
Telegram Group t.me/LeadCoding
Leetcode Hard :- • Hard
Leetcode Medium :- • Medium
Leetcode Easy :- • Easy

Пікірлер: 18

  • @ashishchoudhary4517
    @ashishchoudhary4517 Жыл бұрын

    Thank you for putting this up. Pretty nice approach.

  • @lakshaysharma852
    @lakshaysharma852 Жыл бұрын

    Superb Explanation

  • @akanshkumar2876
    @akanshkumar28763 жыл бұрын

    Took me 2 hrs to understand the solution clearly as i didnt know DSU But it was worth it..

  • @rajawatlks
    @rajawatlks3 жыл бұрын

    Nice Explanation

  • @gauravkumarsharma5904
    @gauravkumarsharma59043 жыл бұрын

    Khatarnak Logic

  • @Aysh_Sach_16-2
    @Aysh_Sach_16-23 жыл бұрын

    buddy pls explain problem 4th also 1723. Find Minimum Time to Finish All Jobs

  • @HIMANSHUPATEL002
    @HIMANSHUPATEL0023 жыл бұрын

    I think DSU will define the time complexity so it will be O(nlogn)

  • @VickyGupta538
    @VickyGupta5383 жыл бұрын

    How did you get the idea of maintaining maps of unions and incrementing it for source and decrementing for target? Please share it. It is also one of the important aspect of this problem. Also share other ways to do it instead of maps of unions.

  • @mohammadfraz

    @mohammadfraz

    3 жыл бұрын

    I usually go for maps when I have to maintain a count. Here I wanted to used kind of 2D map, so I used a map of map.

  • @kollivenkatamadhukar5059
    @kollivenkatamadhukar50593 жыл бұрын

    at 8:04 how there is a difference at 3 and 2 ie 4 and 2 I hope why we are interchanging them unnecessarily

  • @learner_1228
    @learner_12283 жыл бұрын

    why ans /=2? could you please explain?

  • @jayasingh5519

    @jayasingh5519

    3 жыл бұрын

    Because actually you are adding the number of differences twice, If there are three ones in source and two ones are in target the difference is 1 i.e there will be one position mismatch or you can say one '1'will never be matched and suppose at that mismatch position, there is 5 in target array then you will add abs(-1) for 5 too which will make count 2 for just one mismatch. 😊

  • @SachinKumar-ud2er
    @SachinKumar-ud2er3 жыл бұрын

    why didn't you used unordered_map instead of map, it's complexity is O(1)?

  • @mohammadfraz

    @mohammadfraz

    3 жыл бұрын

    yes You can use that.

  • @rajawatlks
    @rajawatlks3 жыл бұрын

    Hey can you tell me which application you are using for the explanation. name ?

  • @rajawatlks

    @rajawatlks

    3 жыл бұрын

    Bhai.... reply BHI Karna hota y

  • @ajaydabas7872

    @ajaydabas7872

    3 жыл бұрын

    @@rajawatlks Microsoft OneNote

  • @rehanakhter4813
    @rehanakhter48133 жыл бұрын

    why its ans/2 not ans only?