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

Поделиться
HTML-код
  • Опубликовано: 20 авг 2024
  • In this video, I'll talk about how to solve Leetcode 310. Minimum Height Trees | BFS | Topological Sort | Graphs
    Let's Connect:
    📱Discord (Join Community) : / discord
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / ez.pz.dsa
    💻 Twitter - / aryan_mittal007
    🤖 Github: github.com/ary...
    About Me:
    I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Комментарии • 40

  • @ARYANMITTAL
    @ARYANMITTAL  4 месяца назад +16

    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❤💻

    • @user-no5mo9jv5m
      @user-no5mo9jv5m 3 месяца назад

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

    • @keshavagarwal5900
      @keshavagarwal5900 3 месяца назад +2

      Bro,A recommendation from my side.Today I searched MINIMUM HEIGHT TREE ON RUclips.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 RUclips IS NOT RECOMMENDING UR VIDEOS OR RUclips ALGORITHM IS NOT PUSHING UR VIDEOS.THEREFORE ,U SHOULD DO SOMETHING TO RESOLVE THIS BCZ UR VIDEOS DESERVE TO GET MORE REACH.

    • @user-no5mo9jv5m
      @user-no5mo9jv5m 3 месяца назад

      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 3 месяца назад +3

    The chain example was just mind blowing!

  • @codingkart245
    @codingkart245 3 месяца назад +2

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

  • @shubhammittal4389
    @shubhammittal4389 3 месяца назад

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

  • @SANJITNAVEEN
    @SANJITNAVEEN 3 месяца назад

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

  • @lakeshkumar1252
    @lakeshkumar1252 3 месяца назад +2

    thanks for consistently uploading videos

  • @ujjwalrockriser
    @ujjwalrockriser 3 месяца назад

    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.

  • @ShubhamSingh-ud1mw
    @ShubhamSingh-ud1mw 3 месяца назад

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

  • @HimanshuYadav-no4ul
    @HimanshuYadav-no4ul 3 месяца назад

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

  • @muhiwaraa
    @muhiwaraa 3 месяца назад

    Your style ❤

  • @kergeysarjakin5592
    @kergeysarjakin5592 3 месяца назад +1

    Bro loved your intuituion you are the best .

  • @shivchauhan795
    @shivchauhan795 3 месяца назад

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

  • @2amCoder
    @2amCoder 4 месяца назад +1

    Nice work Bro!

  • @insaneclutchesyt948
    @insaneclutchesyt948 3 месяца назад

    Excellent Explanation , thank you

  • @vanshikaahuja766
    @vanshikaahuja766 3 месяца назад +1

    it is jst so awsmm🤯🤯

  • @tanyaraj3129
    @tanyaraj3129 3 месяца назад

    good to go chief

  • @akankshamore7111
    @akankshamore7111 3 месяца назад

    Excellent explanation!!!!!

  • @decodingNikhil
    @decodingNikhil 3 месяца назад +2

    2:26 bohot yaarana lagta hai XD

  • @shivamjuyal3996
    @shivamjuyal3996 3 месяца назад

    excellent explanation bhai !!

  • @muntajir646
    @muntajir646 3 месяца назад +1

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

    • @user-cv6ed5cb9c
      @user-cv6ed5cb9c 3 месяца назад +1

      NO Cpp Better. U need to learn Cpp🙂🙂

    • @muntajir646
      @muntajir646 3 месяца назад

      @@user-cv6ed5cb9c 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

    • @user-cv6ed5cb9c
      @user-cv6ed5cb9c 2 месяца назад

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

  • @e2_04_abhijeetkumarsingh6
    @e2_04_abhijeetkumarsingh6 3 месяца назад

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

  • @swastisrivastava4987
    @swastisrivastava4987 3 месяца назад

    Thankyou... helpful

  • @vijaybenz9741
    @vijaybenz9741 3 месяца назад

    nice

  • @JIGARSINGTHAKOR-yy6qp
    @JIGARSINGTHAKOR-yy6qp 3 месяца назад

    can i use priority queue instead of simple queue ?

  • @diva573
    @diva573 3 месяца назад

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

  • @bhavaygoel
    @bhavaygoel 3 месяца назад

    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.

  • @harikeshkumarsharma6730
    @harikeshkumarsharma6730 9 дней назад

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

  • @gilfoyle2211
    @gilfoyle2211 3 месяца назад +1

    karo bhai subscribe krte kyu nahi!!

  • @arreactor2146
    @arreactor2146 3 месяца назад +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 3 месяца назад

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

    • @arreactor2146
      @arreactor2146 3 месяца назад

      @@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 3 месяца назад +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 Месяц назад

      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.