Copy List with Random Pointer ( with extra space ) | EP 23

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 53

  • @husler7424
    @husler7424 2 роки тому +10

    I watched Striver and many other videos for this but didn't understand. Your explanation for LinkedList videos are really easy to get. Thanks Fraz.

  • @RishavRaj-kn8nm
    @RishavRaj-kn8nm 2 роки тому +1

    Bhaiya aap bhaut accha explain karte ho.Mtlb ek dum basics se explain kiya aapne aur aaram aaram se pura question samjha diya.Superb

  • @desihiphop4998
    @desihiphop4998 3 роки тому +1

    Question - accha
    Explanation - accha*100
    Bhaiya aapka question selection op hai bhut op !!!!!!

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

    very easy explanation as compared to other youtubers. thanks

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

    I also watched the same problem in other channels but didn't understand a bit.
    Here, I found best explanation

  • @kalpeshmali1476
    @kalpeshmali1476 3 роки тому +2

    so depth explanation for complex problems ❤️❤️❤️❤️🔥🔥🔥🔥🔥

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

    Really superb explanation

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

    1. BRUTE APPROACH(Recursion + HashMap):-
    --------------------------------------------------------------------------
    class Solution {
    public:
    unordered_map m;
    Node* dfs(Node* node){
    if(!node) return NULL;
    if(m.find(node) != m.end()) return m[node];
    Node* newNode = new Node(node->val);
    m[node] = newNode;
    newNode->next = dfs(node->next);
    newNode->random = dfs(node->random);
    return newNode;
    }
    Node* copyRandomList(Node* head) {
    return dfs(head);
    }
    };
    // Time Complexity = O(n)
    // Space Complexity = O(n)
    2. OPTIMIZED APPROACH(HashMap) - By Fraz Bhaiya (from this lecture):-
    ----------------------------------------------------------------------------------------------------------
    class Solution {
    public:
    Node* copyRandomList(Node* head) {
    unordered_map m;
    Node* temp = head;
    while(temp != NULL){
    Node *copy = new Node(temp->val);
    m[temp] = copy;
    temp = temp->next;
    }
    temp = head;
    while(temp != NULL){
    m[temp]->next = m[temp->next];
    m[temp]->random = m[temp->random];
    temp = temp->next;
    }
    return m[head];
    }
    };
    // Time Complexity = O(n)
    // Space Complexity = O(n)
    -----------------------------------------------------------------------------------------------------------------
    Enjoy Guys !!! ❤😉
    I wrote here for revision purpose in future but you can use too for revision :)
    And Thank to Fraz Bhaiya 🙏🥰❣🔥for whole content :)

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

    Perfectly explained sir , I got here after 3 videos and understand this approach here completely .❣️❣️
    One suggestion sir , please use relevent tags and #tags in your description so that your videos pop up as when i searched this problem your video doesn't appear .

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

    This is pure Gold

  • @Sahilsharma-sk5vr
    @Sahilsharma-sk5vr Рік тому

    best video for this question

  • @SunnyGupta00
    @SunnyGupta00 3 роки тому +10

    This series is far better from paid courses, I have seen ❤️

    • @mohammadfraz
      @mohammadfraz  3 роки тому +1

      Thank you so much Sunny ❤️

    • @mohammadfraz
      @mohammadfraz  3 роки тому +2

      Complete bhi krli kya ?

    • @SunnyGupta00
      @SunnyGupta00 3 роки тому +1

      @@mohammadfraz hn😌

    • @thinkingmad1685
      @thinkingmad1685 3 роки тому

      @@SunnyGupta00 saat me code bhi kro bro ese dekhne se fayda nhi hota

    • @SunnyGupta00
      @SunnyGupta00 3 роки тому

      @@thinkingmad1685 hn bhai ab thoda bhaot bhul gaya me 🥲🥲

  • @harshitamendiratta71
    @harshitamendiratta71 3 роки тому +1

    Amazing explanation

  • @Androgamer-yx7tu
    @Androgamer-yx7tu 3 роки тому +1

    Mast 🔥

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

    Suggestion: please use tags like #stack etc... i searched for stack playlist but ur videos didnt show up to me.. its an awesome playlist .. please do this in order to spread this good work

  • @mdsufyankhan1029
    @mdsufyankhan1029 3 роки тому +1

    waited for this explanation , thanks bro ❤️

  • @noob_clasher511
    @noob_clasher511 3 роки тому

    what an interesting solution. Thanks.

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

    how easily he explained such a difficult question ? Thanks a lot Bhaiya

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

    best content ever

  • @HarshRaj-kp7gk
    @HarshRaj-kp7gk 3 роки тому +2

    sir, please make a video on (computer network) preparation in 3 days for placement
    sir , "you forgot it this subject to make a video "
    its humble request sir please make a video as soon as possible

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

    great explanation bhaiya
    I have a little doubt, we are using the map in which we are putting the nodes which are ultimately is going to be part of the answer
    then why space complexity is O(N) it should be O(1)

  • @ankitgarg2760
    @ankitgarg2760 3 роки тому

    hey @Fraz Can you pls provide the optimized solution Explanation of count pairs in array whose product is divisible by k? Rather than proving explanation of questions which are already well explained in several other channels.

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

    Bhaiya video is very helpful bhaiya code ke saath comments bhi likh dijiye

  • @ABC-ks8ir
    @ABC-ks8ir 3 роки тому +1

    Good explanation bro

  • @SunnyGupta00
    @SunnyGupta00 3 роки тому +1

    Reach++ 🔥

  • @bite021devansh8
    @bite021devansh8 3 роки тому +1

    🙏🙏

  • @abhayrai1724
    @abhayrai1724 3 роки тому

    Yaar bhai kisi ka nam to nhi lunga .....bt jo flow and sweetness wale mood se aap sikhate hoo sawaal ek point ke baad logic se khud code kr lete h 🤗🤗🤗 pr baad me repent hota h ki phle aapki hi video kyu nhi on ki😓...keep going ....🙏🥺😍

  • @mdnadeem6343
    @mdnadeem6343 3 роки тому

    too good bhaiya

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

    I'm not able to understand how the links have been made?

  • @abdulrazzak2934
    @abdulrazzak2934 3 роки тому

    nice problem nice video

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

    Bhaiya ye sare concepts enough ha interview ke liya ?
    In linkedlist topic ?
    If some remaining concepts left then please mention

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

      Enough hain

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

      @@mohammadfraz ok bhiaya
      Stack and queue ab kaha se krna chaiye mujhe question jaisa yeh playlist ha waisae koi se

  • @Androgamer-yx7tu
    @Androgamer-yx7tu 3 роки тому +1

    360P pe v HD clarity ati h

  • @madhabkafle8072
    @madhabkafle8072 3 роки тому

    💯

  • @khizrshaikh9902
    @khizrshaikh9902 3 роки тому +1

    First I want heart