310. Minimum Height Trees | BFS | Topological Sort | Graphs

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

КОМЕНТАРІ • 43

  • @ARYANMITTAL
    @ARYANMITTAL  7 місяців тому +17

    Make sure, this is one such problem where Intuition is very important, WHY? is very important, so I'll highly recommend to watch Intuition part, no-one on yt will tell it, they will just show you❤💻

    • @Invasion-p7w
      @Invasion-p7w 7 місяців тому

      This is the reason, you are the knly one i subscribed on YT for DSA. ❤

    • @keshavagarwal5900
      @keshavagarwal5900 7 місяців тому +2

      Bro,A recommendation from my side.Today I searched MINIMUM HEIGHT TREE ON UA-cam.I EXCEPTED UR VIDEO TO BE PRESENT THERE BUT THIS VIDEO WAS NOT IN THE LIST.EVEN I SCROLLED TO THE BOTTOM,THIS VIDEO WAS NOT THERE UNDER THE SEARCH OF"MINIMUM HEIGHT TREE".OTHER CHANNEL VIDEO ON THIS PROBLEM SOLN WAS THERE.THEN I SEARCHED "MINIMUM HEIGHT TREE BY ARYAN MITTAL".THEN ALSO THE VIDEO WAS NOT THERE.UR CHANNEL WAS COMING.THEN I WENT INTO UR CHANNEL AND FROM THERE I FOUND OUT THIS VIDEO.
      SO BASICALLY U DOING SO MUCH HARD WORK AND MAKING QUALITY VIDEOS AND STILL THE VIDEO NOT GETTING MUCH REACH .THE REASON IS THAT THE UA-cam IS NOT RECOMMENDING UR VIDEOS OR UA-cam ALGORITHM IS NOT PUSHING UR VIDEOS.THEREFORE ,U SHOULD DO SOMETHING TO RESOLVE THIS BCZ UR VIDEOS DESERVE TO GET MORE REACH.

    • @Invasion-p7w
      @Invasion-p7w 7 місяців тому

      You could simply subscribe to his channel.
      Also a suggestion, It's harder to read the message with caps lock on. Kindly edit.
      Thanks 🤙🏻

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

    The chain example was just mind blowing!

  • @codingkart245
    @codingkart245 7 місяців тому +2

    Today I got to know the practical implementation of Topological Sort :) Thank you so much!

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

    Best Explaination

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

    intuition is more important than actual algorithm 👍
    GREAT EXPLANATION!!!

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

    dude you the most consistent content creator on internet right now.. that too top notch quality content. keep going man! I am with you

  • @ShubhamSingh-ud1mw
    @ShubhamSingh-ud1mw 7 місяців тому

    very decent logic building and now i totally can think of many diffrent situation where i can use this logic. thanks aryan

  • @SuryaSurya-xo4xt
    @SuryaSurya-xo4xt 3 місяці тому

    Ur explanation is awesome

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

    You explained very well, I also thought similar, but I was doing with visited vector, I was not using the frequency vector. Thank you Aryan Bhaiya, you are my inspiration.

  • @2amCoder
    @2amCoder 7 місяців тому +1

    Nice work Bro!

  • @kergeysarjakin5592
    @kergeysarjakin5592 7 місяців тому +1

    Bro loved your intuituion you are the best .

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

    good to go chief

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

    Excellent explanation!!!!!

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

    Excellent Explanation , thank you

  • @HimanshuYadav-no4ul
    @HimanshuYadav-no4ul 7 місяців тому

    well you helped a lot with your consistency of creating video my upsolving efficincey is very good all because of you

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

    Your style ❤

  • @vanshikaahuja766
    @vanshikaahuja766 7 місяців тому +1

    it is jst so awsmm🤯🤯

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

    excellent explanation bhai !!

  • @lakeshkumar1252
    @lakeshkumar1252 7 місяців тому +2

    thanks for consistently uploading videos

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

    Its really informative. I hope one day I could solve and think intution like you. Inspiration❤

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

    Thankyou... helpful

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

    nice

  • @decodingNikhil
    @decodingNikhil 7 місяців тому +2

    2:26 bohot yaarana lagta hai XD

  • @muntajir646
    @muntajir646 7 місяців тому +1

    Please code in Java it will be really helpful. Thanks for the OP explanation

    • @SDHANUSH-l9u
      @SDHANUSH-l9u 7 місяців тому +1

      NO Cpp Better. U need to learn Cpp🙂🙂

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

      @@SDHANUSH-l9u I am coding in Java since my class 8 so I like Java more haha and there's no difference much it's just preferential

    • @SDHANUSH-l9u
      @SDHANUSH-l9u 6 місяців тому

      @@muntajir646 It is ur wish. But with cpp u get short statements which will really help u

  • @JIGARSINGTHAKOR-yy6qp
    @JIGARSINGTHAKOR-yy6qp 7 місяців тому

    can i use priority queue instead of simple queue ?

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

    bhaiya can u please attach the pdf of the pages that u used here on notepad ??

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

    kaha gayab ho gaye ho bhai .... ba POD kaha se dekhu

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

    Please do code in java and explain that too...

  • @gilfoyle2211
    @gilfoyle2211 7 місяців тому +1

    karo bhai subscribe krte kyu nahi!!

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

    bro your video is not coming in youtube search, are you shadowbanned? please confirm or do something. you are the best and it hurts to see this slow growth.

  • @arreactor2146
    @arreactor2146 7 місяців тому +2

    I solved this question using maximum diameter but iam getting memory limit exceeded passed 70/71 testcases can anyone optimized it
    class Solution {
    vector diam;
    vector maxDiam(int prev, int curr, vector &adj){
    vector temp1, temp2;
    for(auto &it: adj[curr]){
    if(it!=prev){
    vector node=maxDiam(curr, it, adj);
    if(node.size()>temp1.size()){
    temp2=temp1;
    temp1=node;
    }
    else if(node.size()>temp2.size()){
    temp2=node;
    }
    }
    }

    temp1.push_back(curr);
    if(temp1.size()+temp2.size()+1>diam.size()){
    vector node=temp1;
    node.insert(node.end(), temp2.begin(), temp2.end());
    diam=node;
    }
    return temp1;
    }
    public:
    vector findMinHeightTrees(int n, vector& edges) {
    if(n

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

      edge case do a simply check in starting if(n==1) return {0};

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

      @@aastikofficial6100 Recently solved by doing some change in my method
      Here is the code.
      class Solution {
      pair t1={0, 0}, t2={0, 0};

      pair max_pair(pair &p1, pair &p2){
      if(p2.second>=p1.second){
      return p2;
      }
      else{
      return p1;
      }
      }
      pair maxDiam(int node, int prev, vector &adj){
      pair max1={0, 0}, max2={0, 0};
      for(auto &it: adj[node]){
      if(it!=prev){
      pair temp=maxDiam(it, node, adj);
      if(max1.second

  • @aastikofficial6100
    @aastikofficial6100 7 місяців тому +4

    yr vo mja nhi h aapki explananation me thoda over kr dete ho therefore confusion ho jati h just a review from my side like everyone has different views and perspectives rest explanation is okay

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

      Totally agree with you, he over explains some basic parts, due to which the interest breaks down in between while watching. Personally I also love videos with precise explanations.
      But I think he do it purposely so that even a person who is not so much good can understand the intuition.
      And I think nowdays most of the people get that much basic understanding by solving basic problems.