Clone Graph | Leetcode 133 | DFS | Day-23

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

КОМЕНТАРІ • 47

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

    Great, your explanation is so clear and to the point! Thank you :)

  • @itsme-z1s
    @itsme-z1s 3 місяці тому

    good, finally got the logic why we used map

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

    Great I wasn't able to understand the logic by other channels

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

    makes sense, Thanks ayushi

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

    Best explanation. Thank you so much

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

    when we pass the 2 as the current in the dfs. Then the loop goes to the neighbors of 2, which are {1,3}. Assuming 1 goes first, so then we will go into the if statement and push into the vector. but what will be the result of the line of code, neighbour.push_back(dfs(current,map)) what are we pushing ino that vector? thanks

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

    great !

  • @abhishekanand8574
    @abhishekanand8574 Місяць тому

    thanku mam

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

    amazing..

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

    well explained, Ayushi

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

    awesome explanation!

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

    Thanks for the effort.

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

    nice explanation

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

    Best explaination thanku

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

    Nicely explained di

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

    Amazing explanation.

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

    Nice explanation 🔥

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

    nice

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

    Hey, Ayushi in your new video comments are turned off please turn them on (Sort Linked List VIDEO)

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

      Hi Vaidansh, thanks for letting me know. Don't know why UA-cam keeps on disabling comments. 🙂

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

      @@AyushiSharmaDSA Welcome 🤗
      & Thanks to u for u r great explanations
      Keep making videos like this 👍

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

    Ma'am can we do this question if we use a visited map like unordered_map instead of using the map between original graph and new Nodes?

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

      The thing is that we need to get the new node which which we will add in adjacency list of that new node which is created, so we will have to have map

  • @gauravchaudhary6941
    @gauravchaudhary6941 2 роки тому +5

    not a good explanaition

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

      thank you for valuable feedback, will try harder next time :)

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

    Why this question in leetcode has so many dislikes?

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

    hi, is it good to use unordered_map globally as used below (to save some lines of code):
    class Solution {
    public:
    unordered_map mp;
    Node* cloneGraph(Node* node) {
    if(!node) return node;
    Node *ans = new Node(node->val);
    mp[ans->val] = ans;
    for(int i=0;ineighbors.size();i++){
    if(mp.find(node->neighbors[i]->val)==mp.end()){
    ans->neighbors.push_back(cloneGraph(node->neighbors[i]));
    } else {
    ans->neighbors.push_back(mp[node->neighbors[i]->val]);
    }
    }

    return ans;
    }
    };

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

      Hi Jatin, as such there will no problem, but sometime may happen that it already has some previous values, so in starting of function, it would be better if you clear map first and then use it

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

      @@AyushiSharmaDSA Got it. Thanks.