"himmat chahiye yaha tak dekhne ke liye " -> this make me more motivated bhaiya thanks
@heerathakur2680 Жыл бұрын
Honestly speaking, I think you are the only one who has made these kind of crisp and to the point videos by covering all the topics on binary trees. Thank You
@sambhavsharma27802 жыл бұрын
Sir in k Sum Path question there is no need to pop_back from path vector because in every auxiliary stack call path vector having a different memory because we passes as a call by value. pop_back() function is needed when we do call by reference like vector &path.
@oniii-chan_ Жыл бұрын
29:35 Problem in the question in K sum path is that the complexity of our code is O(N^2) but expected is O(N)
@34-devendrasinghit18 Жыл бұрын
here we have used map and optimised it. class Solution { public: #define ll long long map mp; int ans=0; void solve(TreeNode* root, int targetSum,ll currSum){ if(root==NULL) return; currSum+=root->val; ans+=mp[currSum-targetSum];//it mean between the ongoing process there is a place where targetSum is generated. mp[currSum]++; solve(root->left , targetSum,currSum); solve(root->right , targetSum,currSum); mp[currSum]--; currSum-=root->val; } int pathSum(TreeNode* root, int targetSum) { mp[0]++; ll currSum=0; solve(root,targetSum,currSum); return ans; } };
@amitprakhar4802 Жыл бұрын
@@34-devendrasinghit18 bhaiya wala code to gfg pe run hogya but hmare me nhi ho rha
@shashankjangir1873 Жыл бұрын
@@amitprakhar4802 bhaiya ke computer pe jake ke kr run
@amitprakhar4802 Жыл бұрын
@@shashankjangir1873 tune wahii kiya tha kya 🤣🤣
@mr.dependable4885 Жыл бұрын
@@amitprakhar4802 testcase update hue hai uske
@Singh112252 жыл бұрын
Binary trees are my fav data structures. Didn't get any question related to it ever in an interview but I enjoyed these questions the most when I was preparing.
@divyareddy76222 жыл бұрын
Divya Reddy 1 second ago did you complete kth ancestor in a tree problem using the vector which was given as homework? this code is not working :( int kthAncestorsol(Node *root, int k, int node, vector &path) { if(root == NULL) return 0; path.push_back(root->data); if(root->data == node) { for(int i =0; ileft, k, node, path); kthAncestorsol(root->right, k, node, path); } int kthAncestor(Node *root, int k, int node) { vector solu; kthAncestorsol(root, k, node, solu); }
@ashishpal50882 жыл бұрын
Bhai java vala koi hai other ancestor ka question Mahi ho Raha hai
@deveshbisht9262 жыл бұрын
@@divyareddy7622 try this int solve(Node* root, int k, int node, vector& path){ if(root == NULL) return 0; path.push_back(root->data); solve(root->left, k, node, path); solve(root->right, k, node, path); int size = path.size(); for(int i=size-1;i>=0;i--){ if(path[i] == node){ int index = i-k; if(index
@titaniumcoders67102 жыл бұрын
@@deveshbisht926 😀
@namanjain7949 Жыл бұрын
run time error ! @@deveshbisht926
@RishiRajVishwakarma-le7xv Жыл бұрын
Not Just DSA but this playlist is also teaching me consistency and kind of attitude that is required to crack some major companies.
@adityakishore5946 Жыл бұрын
Can someone tell me the case where the value of k becomes less than 0 in the Kth Ancestor in a Tree problem.
@rickseth9207 Жыл бұрын
@@adityakishore5946 can you be more specific?
@rickseth9207 Жыл бұрын
@@adityakishore5946 just a matter of coding style you can actually just write k==0 and the code would work just fine.
@akashpartel73917 ай бұрын
@@adityakishore5946 the value of k can not be less than 1, let alone 0. what do you say the 0th ancestor of a node is? the counting starts from 1; 1st ancestor: just above it; 2nd ancestor: two level above it; and so on.
@aishwaryaporwal23212 жыл бұрын
No words can define ur consistency n efforts ... Thank you so much♥️💯💯
@17_sidhantbahri66 Жыл бұрын
paid comment
@aishwaryaporwal2321 Жыл бұрын
@@17_sidhantbahri66 okk then u can pay me?? 😂😂
@mansoorrr9167 Жыл бұрын
@@17_sidhantbahri66 sharam Karo itni mehnat karke free se first class se padarahe bhaiyya aur tum jaise log aisa comment Karthee ho
@rickseth9207 Жыл бұрын
@@17_sidhantbahri66 Indians really know how to kill some person's spirit, chalo maan bhi liya paid hai toh kya? tum tareef na karke agar burai he karoge toh iss situation mai atleast paid comments tareef toh karenge
@vmstudy99657 ай бұрын
Koi dekhta ni h yha Tak. Mehnat lgti h yha tk tikne k liye. Sir ekdm right baat kahi aapne❤
@hritiksingh9873 Жыл бұрын
instead of putting if(k
@vikasjat1170 Жыл бұрын
No bro, all test cases are not passing
@supersuperhero2449 Жыл бұрын
@@vikasjat1170my all case passed by this, k==0 , and then simpy return root
@stevebucknor7058 Жыл бұрын
Well, that is what i did
@vakeelsaab5485 Жыл бұрын
@@vikasjat1170 Node* solve(Node *root, int& k, int node) { if(root==NULL) return NULL; if(root->data==node) return root; Node*leftans=solve(root->left,k,node); Node*rightans=solve(root->right,k,node); if(leftans!=NULL && rightans==NULL) { k--; if(k==0) { return root; } return leftans; } if (leftans==NULL && rightans!=NULL) { k--; if(k==0) { return root; } return rightans; } return NULL; } int kthAncestor(Node *root, int k, int node) { Node*ans=solve(root,k,node); if(ans==NULL || k>0) return -1; else return ans->data; } This code works perfectly for all test cases there is no need to changing k to INT_MAX
@janvisharma23778 ай бұрын
great video , I learned a lot from your lectures thank you very much for that much efforts ❤❤
@srajittanwar6362 жыл бұрын
Thank you so much for increasing the number of questions. Itna jaldi toh koi paid course me bhi respond nhi krta
@shashanksingh49682 жыл бұрын
Wish peeps like you were there when we started college back in '16. We never wrote a line of code for tree and other advanced topics, we studied theory. Now working in service based company, with goal to work in PBC soon, you came as messiah, no amount of words will be enough to thank you. ❤❤❤
@ajayjaadu422 жыл бұрын
,,,
@alexrcrew19752 жыл бұрын
bro where u work at present?
@SaurabhKumar-vr3xc2 жыл бұрын
bhaiya , is important to lock k. we can also do it by doing if(k==0) { return root; } if any of one(leftans or rightans) is not NULL because we are not going to increase K again when K touches 0.
@shubhamshah98372 жыл бұрын
Best playlist for DSA!! Thank you so much for this❤❤
@AdityaKumar-tb9he2 жыл бұрын
man kre to krna na kre to mt krna are kaahe nhi krega aap pada hi itna badiya rhe ho thanku bhaiya ji
@AbhishekGupta-cg2vj2 жыл бұрын
No words can define ur consistency n efforts ... Thank you so much
@thecrazyfilmygyan550Ай бұрын
honestly sir u are the reason who made the DSA easy
@kritarthtripathi97932 жыл бұрын
Consistency and content is on next level...THANK U SO MUCH❤
@shriRam.3122 ай бұрын
thankyou so much bhaiya You are only one person who honestly teaching every topic with full effort like dry run and many more thank you🙏🙏🙏🙏🙏🙏
@rohitsingh59552 жыл бұрын
Great Work ! , just one thing in Que 3. path.pop_back() is not required since we are not passing it by reference . Added element will get removed automatically going back up the tree.
@shivamsehrawat76102 жыл бұрын
It's mutable unlike strings and int so its required I think
@shubhammittal53422 жыл бұрын
@@shivamsehrawat7610 no bro its not req only if we pass by ref then we had to manually pop it
@sagarsen58562 жыл бұрын
Isn't an array is always passed by reference
@worldfromhome40332 жыл бұрын
I don't get one thing....how is the code working without passing it by reference??
@prashantMishra-it2im2 жыл бұрын
True
@thisismr900 Жыл бұрын
im confident enough now with these trees. Just mentioning for solving LCA it took 27min.12s to complete it by myself totally. Thank you for all teachings. and transforming lallus to shers
@rakhshanahmad8057 Жыл бұрын
Love the step-by-step approach you take in your lectures - it makes the concepts easier to grasp. Thanks for the helpful explanation of the concept.❤
@SHAKIBANSARI8933 ай бұрын
"Banda Raat Raat Bhar Jagta Hai ", Heart touching movement❣❣❣❣
@PrashantSinghRajawat22 Жыл бұрын
Day 61 and lecture 65 .. consistently, I'm watching your videos. A great thanks to you Bhaiya for this course ...Bhaiya your consistency inspires me to be consistent and don't give up ..
@utkarshtipre7121 Жыл бұрын
itna detail solution batane wala ek hi banda hai,....love bhai.
@riyajain36552 жыл бұрын
Great video!, also one thing you dont need to call pop_back function on path vector in K Sum Paths question as vector is called by value so it wont bother Thanks for making a great course for free
@amarnathprajapati2543 Жыл бұрын
Sir, आपके निस्वार्थ मेहनत के आगे मै शब्दहीन हो गया हूँ।।
@shreyagupta22822 жыл бұрын
I was never able to do tree problems but by watching last three videos of tree questions you have made my concepts clear to a great extent...Thank you sm for your efforts 🤗❤.....Please make us understand all questions of Dp and graph also so easily😂🙏🏻
@divyareddy76222 жыл бұрын
Divya Reddy 1 second ago did you complete kth ancestor in a tree problem using the vector which was given as homework? this code is not working :( int kthAncestorsol(Node *root, int k, int node, vector &path) { if(root == NULL) return 0; path.push_back(root->data); if(root->data == node) { for(int i =0; ileft, k, node, path); kthAncestorsol(root->right, k, node, path); } int kthAncestor(Node *root, int k, int node) { vector solu; kthAncestorsol(root, k, node, solu); }
@torus1512 жыл бұрын
@@divyareddy7622 you have made mistake......the if condition in recusrion function should be bellow the left and right call...hope u got it
@divyareddy76222 жыл бұрын
@@torus151 no I tried it's not working even after that
@dep24602 жыл бұрын
@@divyareddy7622 your kth ancestor fxn has return type int ,so when calling left part and right part it will return some value, based on that it will have multiple cases . So I would suggest it make Node * return type and check ancestor in main function by traveling your vector. If not understood I will send the code.
@shubhamkathiriya3830 Жыл бұрын
appriciate your efforts!! job + video recording + finding the best content and questions and all these in free hats off!!
@Profnegi Жыл бұрын
last tak dekha full samaj aaya sai me kamal ho gya bhaiya bs ye hai ki merko abhi code dhang se bnana nahi aata but i know practice ke bad pkka bna llunga mai thx.........................................................................
@gargkapil2 жыл бұрын
Best learning series on KZbin. Because of this series, I am fully motivated to learn it completely.
@akkadBakkad_BambeBo Жыл бұрын
bhaiya, i am watching this playlist offline as internet is not readily available. And everywhere around me when i hear word DSA, everyone talks about your playlist. Thanks for this playlist. It's very helpful.
@programmercoder30002 жыл бұрын
In kth ancestor problem, there is no need to lock the answer by doing k=INT_MAX, we can just change the if condition to k==0
@mukib_khan_2 жыл бұрын
does it give correct output for all cases?
@udaytewary38092 жыл бұрын
really thankyou bhaiya apki wajah in sb topic me dhire dhire confidence aa rha h
@therealartist99 ай бұрын
bhaiya pls give dry run dont go so fast just by writing the codes only
@KRISHNANANDMISHRA-b6y Жыл бұрын
first question easy approch int maxsum = 0; int maxheight = 0; void solve(Node* root, int sum , int height ){ //base case if(root == NULL){ return; }//firstly we store sum variable sum = sum + root->data; if(height>= maxheight){ maxheight = height; maxsum = sum; } solve(root->left,sum,height+1); solve(root->right,sum,height+1); } int sumOfLongRootToLeafPath(Node *root) { solve(root,0,0); return maxsum;
@imamamr Жыл бұрын
In question 3 its given that we need to return ans modulo 10^9 +7 as the count can be very large.
@govindsuryavanshi6653 Жыл бұрын
First I have completed all DSA series and now conclude this is Greatest ever DSA series to exist on youtube or paid courses. Your contribution will be remembered. You're God of DSA for us🙇♂ Thanks you.
@Kishan_Kumar_147 ай бұрын
Learning Dsa from your series sir. It's great help for student community who's desired to learn coding & Dsa. It's have been 2 year of this series. But still no one have taught dsa with such a great explaination. Thnq love babbar bhaiya❤
@noumankhan76622 жыл бұрын
Best playlist for DSA ever seen😇
@mayankuniyal46606 ай бұрын
If i have upskilled myself in DSA is just because of this man...Lots of respect sir
@luckydewangan59852 жыл бұрын
It took me 3hours for understanding every questions with codes and taking notes. Finally heading to next video. Thankyou so much bhaiya for such hard efforts and high quality content.
@snipper66832 жыл бұрын
bhaiya harr video k=last tak dekhta hu and majaa bohot ara hai ; god bless u
@suvigyabasnotra73782 жыл бұрын
Even DJ couldn't stop your consistency!
@its_nawed4611 Жыл бұрын
I have no words to praise your efforts to teach us bhaiya ...❤Thankyou so much ...and han samjh me aa rha hai bhot achhe se
@vaishnavrushikesh40222 жыл бұрын
Really good content. Very good explanation and consistency. I really like this course. Thank you love babbar.
@AyushGupta-ji5xp Жыл бұрын
your explaination of every approach is the best part of this playlist
@ChiragVashisthaBEC Жыл бұрын
literally thank you for all the hard work you have put into making these videos, people like you have been empowering the youth of India to upskill and get placement, this empowerment means everything for students like me to gain a sense of direction in a tuff question to ask my self will it all be worth one day?
@JatinKumar-w7f7 ай бұрын
As per my observation, you have to add " return ;" in the end of solve function of finding k sum path, because without it , it becomes hard to return from recursion and the time complexity of your code is O(n^2),
@rishabhkesarwani95062 жыл бұрын
best teacher ever on DSA, and the best part is approach( algo making) thanks a lot bhaiya.
@divyagupta6854 Жыл бұрын
I watched all the three parts of this FAANG interview question series. Shuru mein laga tha ki pata nahi complete kar paunga ki nahi poore videos, par har video ko end tak dekha, samay laga thoda, par worth it tha totally. Keep bringing us such helpful series Babbar. Hats off!
@SakshamPanpaliya Жыл бұрын
The amount of respect you deserve is out of this world!! Heads up to your hardwork.
@KeshavAgarwal-ix6qx5 ай бұрын
Great appreciation for your work sir!
@asifmondal76092 жыл бұрын
I'm greatly proud on my real teacher sir ‼️😊 Keep growing and keep teaching us ♥️
@harshpandey4190 Жыл бұрын
Thankyou So Much, Confidence is Increasing day by day
@satyamupadhyay83262 жыл бұрын
Following your course since last month and it's been an amazing journey till now.......learning new ways to solve a problem. Thanks a lot for your consistency, seeing you being consistent makes me get up and do the hustle.
@ashishkundara-83552 ай бұрын
hardwork ko salam sir....
@CuriousNagpal Жыл бұрын
Thank you for the amazing content on DSA. I think this is my 27th video in the last 4 days. I have my Google interview in the next couple of days. Will definitely post back about how it goes. And if I am successful in cracking it, you are going to be a very big reason for it! Thanks again for spending so much time and helping me out❤
@mohdkhaleeq7468 Жыл бұрын
Is google currently hiring for sde 1 fresher
@SACHINPCE22CY0512 ай бұрын
Bhaiya aapki mehnat kitni years tak kaam aarhi hia aur aati rhegi ... the best explaination ever ..... really very premium content ans easiest explaination ...... i am following this series from 1st of vedio and its superb .... thanx bhaiya for this
@suvigyabasnotra73782 жыл бұрын
Hum bhi aapki tarah Mehnat maar rahe hain. Got to sleep only 3.5 hrs in the last week. And colleges are about to open physically next month, so here's hoping most of this course gets covered before that, so we wouldn't need to bear further time crunch.
@shivakashyap5017 Жыл бұрын
one of the best DSA course on youtube, thanku very much bhaiya❤❤ for providing us this for free
@sahilpanchasara2 жыл бұрын
Le other paid DSA courses: we have best resources. Le Love Bhaiya: Hum bhi bana lenge vobhi free me 🔥🔥🔥🔥🔥
@vishakhaborkar63362 жыл бұрын
but ab to paid kardiya bhaiyane
@KunalKumar-tp1cc Жыл бұрын
Q4. can be done in kinda similar way in which bhaiya did but without ans locking... bool solve(Node *root,int &k, int node,int &ans){ if(root == NULL) return false; if(root->data == node) return true; bool left = solve(root->left,k,node,ans); bool right = solve(root->right, k,node,ans); if(left||right){ k--; if(k==0) ans = root->data; return true; } return false; } int kthAncestor(Node *root, int k, int node) { int ans; solve(root,k,node,ans); if(k>0) return -1; // If k is greater than required distance b/w nodes. return ans; }
@shubhampatel_2745 Жыл бұрын
Good approach really appreciate you
@ravipandya74112 жыл бұрын
for K sum path : Mistake: TC can not be O(N). TC will be O(N * No. of nodes in vector)
@prayagpatel91362 жыл бұрын
and also path.pop_back(); is not required.
@divyareddy76222 жыл бұрын
did you complete kth ancestor in a tree problem using the vector which was given as homework? this code is not working :( int kthAncestorsol(Node *root, int k, int node, vector &path) { if(root == NULL) return 0; path.push_back(root->data); if(root->data == node) { for(int i =0; ileft, k, node, path); kthAncestorsol(root->right, k, node, path); } int kthAncestor(Node *root, int k, int node) { vector solu; kthAncestorsol(root, k, node, solu); }
@vaibhavdhiman16902 жыл бұрын
@@divyareddy7622 int solve(Node *root, int k, int node, vector &path){ // base case if(root == NULL) return 0; // if node found if(root->data == node) return node; path.push_back(root->data); // traverse int left = solve(root->left, k, node, path); int right = solve(root->right, k, node, path); if(left == node){ return left; } else if(right == node){ return right; } else if(left != node){ path.pop_back(); return 0; } else if(right != node){ path.pop_back(); return 0; } } int kthAncestor(Node *root, int k, int node) { vector path; solve(root, k, node, path); int response = -1; int size = path.size(); for(int idx = 0; idx
@saurabhrthakur11 ай бұрын
@@vaibhavdhiman1690 thanks brother.
@succesmantramotivational87958 ай бұрын
because we are poping back while returning and upar se atte vakt N times and return vector ke through ja rhe hain toh toh jitne baar pop krr rhe hain utne baar vector count ho rha hain
@theelysianone6033 Жыл бұрын
lovely explanation sir, highly appreciated that you're teaching in such detail for free...
@adityagosavi81862 жыл бұрын
For K sum question, there is no need to pop the element after each call, because we dont use path vector by reference here in the solve() function.
@arthurlewin19522 жыл бұрын
Do you think after we have found sum== k the loop should break
@praveennemagoudar344211 ай бұрын
I gained confidence in thinking recursively. Thank you Bhaiya. Everyone should draw recursion tree and understand the flow. Then it becomes easy to write code.
@deepakgoyal1643 Жыл бұрын
Homework - find kth ancestor by using vector Node* solve(Node* root, int k, int node, vector& path, int &ans){ if(root == NULL) return NULL; path.push_back(root->data); if(root -> data == node) return root ; Node* left= solve(root->left, k, node, path, ans); Node* right= solve(root->right, k, node, path, ans); if(left !=NULL || right !=NULL){ int size = path.size(); for(int i=0;i
@ananyapandey8162 Жыл бұрын
bhai solution bhut achi tarah likha hai
@faizannabi4824 Жыл бұрын
Thanks for making these videos free and putting so much effort into these losing your sleep.
@swapnilsalunke5942 Жыл бұрын
The best teachers teach from the heart. Thank you for all that you do!
@jatinnirwan8122 жыл бұрын
Finally uderstood Binary Tree thank you for easily explaining complex question
@yayyayayy2 ай бұрын
Thank you so much for this course!! This is much much more than paid coursesssss
@inter39887 ай бұрын
I just completed the video in 3 hours. Great work. The codes are so much fun
@vanshitamishra4964 Жыл бұрын
aapki mehnat dekh k hum mehnat kar rhe hai bhaiyya, you're the best.
@ananyakhandelwal40512 жыл бұрын
None of the biggest KZbin channel can provide this type of quality content, teaching so nicely without even having experience in teaching.
@prabhatdwivedi4141 Жыл бұрын
last k 30 second dekh k aaj pta ni kyu emotional feel hua love you bhaiya
@SovanMajumder Жыл бұрын
learning late but learning is great with you... Bhaia really you are my motivation. When I feel sleepy I just watch the last part of your videos.
@abdulhaadi81783 ай бұрын
Always watch till very end ... Watching this to the point U said "99% bhag jty hon gy yhn tk"
@shismomin11729 ай бұрын
This is one of the best course for beginners to learn DSA
@vishalgarna4580 Жыл бұрын
You are a great power to become future of students big heart ❣️❣️❣️😊😊😊
@chiragyadav54672 жыл бұрын
east or west , love bhaiya is the best and teaching method is super best
@freefiregamers1345Ай бұрын
Two words for you is The Best Teacher.....................................................
@AnitaBarkhane-c9i2 ай бұрын
LOVE BABBAR IS BEST , Bhai understood hai sab and main thing is that he is teaching us in hindi.
@vanshikasoni69502 ай бұрын
Big salute to creators like you 🙏🙏
@ratneshsingh840311 ай бұрын
No words for you bhaiya, you make me fall in love with DSA, Thts why you are the king of DSA, God of DSA.
@RohanKumar-nt7xq Жыл бұрын
One of the best course of DSA on KZbin .
@AnilKumarPatidar11 Жыл бұрын
To be honest, this Tree series is very good bhaiyya, and if I listen to your voice, things get automatically. very very Thanks bhaiyya.😊
@CollegeInsightsUnlocked10 ай бұрын
love the way u explain each and every concept in a detailed manner.
@keshavgarg8554 Жыл бұрын
Bhahiya I can Comment thousand times, the way you have taught is just fabulous. Respect your hard work!! Again, Thanks for these fantastic lectures!
@AmanBansal-h2k Жыл бұрын
Thankyou so much bhaiya, I understand everything of this lecture 😊
@suplavpandey834510 ай бұрын
sir we are enjoying the way you taught all topics . Thank you sir .
@aayushsaxena7982 Жыл бұрын
Your teaching is superb Learned DSA because of you only
@beastndvk200324 күн бұрын
Best explanation sir ...every concept is crystal clear
@piyushsonigara5550 Жыл бұрын
59:00 Nahi bhagenge pura dekhenge VAMOS! 🔥🔥🔥 Kya question karwaye hai , quantity + quality dono hai unreal man.
@vishwasverma4422 Жыл бұрын
thank you so much bhaiya for adding huge values to our lives both academically and humanely!
@harshalpatil64825 ай бұрын
K Sum paths time complexity is O(N*H) where H stands for height
@jaikhatri47832 жыл бұрын
Bhaiya thank you problem solving skills bhi better ho rahi hai main bhi apke sath solution soch pata hu
@iconic7357 Жыл бұрын
problem in the path sum iii question is our code's time complexity is o(N^2) but expected is o(N)
@shubhamshah98372 жыл бұрын
Thank you bhaiya , the way you explain every question is awesome , you are the best tutor, 🔥🔥
@apurav36310 ай бұрын
Great job sir, kafi achhe se samjhaya aapne thankyou