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
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❤💻
This is the reason, you are the knly one i subscribed on YT for DSA. ❤
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.
You could simply subscribe to his channel.
Also a suggestion, It's harder to read the message with caps lock on. Kindly edit.
Thanks 🤙🏻
The chain example was just mind blowing!
Today I got to know the practical implementation of Topological Sort :) Thank you so much!
intuition is more important than actual algorithm 👍
GREAT EXPLANATION!!!
dude you the most consistent content creator on internet right now.. that too top notch quality content. keep going man! I am with you
thanks for consistently uploading videos
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.
very decent logic building and now i totally can think of many diffrent situation where i can use this logic. thanks aryan
well you helped a lot with your consistency of creating video my upsolving efficincey is very good all because of you
Your style ❤
Bro loved your intuituion you are the best .
Its really informative. I hope one day I could solve and think intution like you. Inspiration❤
Nice work Bro!
Excellent Explanation , thank you
it is jst so awsmm🤯🤯
good to go chief
Excellent explanation!!!!!
2:26 bohot yaarana lagta hai XD
excellent explanation bhai !!
Please code in Java it will be really helpful. Thanks for the OP explanation
NO Cpp Better. U need to learn Cpp🙂🙂
@@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
@@muntajir646 It is ur wish. But with cpp u get short statements which will really help u
bhaiya can u please attach the pdf of the pages that u used here on notepad ??
Thankyou... helpful
nice
can i use priority queue instead of simple queue ?
Please do code in java and explain that too...
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.
kaha gayab ho gaye ho bhai .... ba POD kaha se dekhu
karo bhai subscribe krte kyu nahi!!
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
edge case do a simply check in starting if(n==1) return {0};
@@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
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
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.