Maximum Depth of Binary Tree | Height of Tree| Tree Data Structure playlist C++ | Hello World

  Рет қаралды 11,307

Hello World

Hello World

Күн бұрын

Пікірлер: 67
@hikikomori9387
@hikikomori9387 Жыл бұрын
I don't know how do we even learn to think like that, the way you came up with the solution recursively, already having an intution what the final recursive call going to return and building up to the final solution. Do people who are really good at DSA just born with this talent? or does it come from practice. I don't think I'll even be able to be as good as you or any other DSA KZbinr. Some people are too good to be true. I'm really beating myself over it and getting depressed.
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
nobody born with the talent expect Karna ( in mahabharat ) and u don't need to be like me or any other KZbinr u just have to be better than yourself bass be consistent buddy u will do it
@supriyamanna715
@supriyamanna715 Жыл бұрын
woah woah woah, bhaiya has seen enough rejections and a hell lot of wrong ways of solving problems which make his explaination so easy, its same for all
@AAYUSHSHARMAPCE21CS002
@AAYUSHSHARMAPCE21CS002 6 ай бұрын
Finally I understood this topic just because of you!!!! Thankyou sirr!!!!❤
@akulanvn381
@akulanvn381 Жыл бұрын
Bhaiya you are the best in explaining thank you yaar. i understood everything so clear.
@ferozekhan4021
@ferozekhan4021 Жыл бұрын
Bhut acha smjhaty ho bhai. Thank u 🎉
@satyaprakashsingh952
@satyaprakashsingh952 2 жыл бұрын
Guru ji pan papper wala sabse best hai isi pr continue rhiye
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Thanks 👍 dude
@kamalkushwaha4908
@kamalkushwaha4908 2 жыл бұрын
Got more clear understanding...Thanks🙏
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Thanks for sharing feedback
@vitaminprotein2217
@vitaminprotein2217 2 жыл бұрын
we can do straight bfs traversal as height of the tree would be= no.of levels,but ya if height of left and right sub tree are asked the we can do like as taught vector ans; // edge case if(!root) return 0; queue q; q.push(root); while(!q.empty()) { vector temp; int size = q.size(); for(int i=0; ileft) q.push(node->left); if(node->right) q.push(node->right); temp.push_back(node->val); } ans.push_back(temp); } return ans.size(); }
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
yes bro
@rohitsoni5491
@rohitsoni5491 7 ай бұрын
Great Video Brother :) my friend suggested your tree videos, truly commendable.
@AnkitKumar-oz6wl
@AnkitKumar-oz6wl 2 жыл бұрын
Bhaiya hum root->left mei kitne node hai unko store kar lenge ek variable mei and then root ->right ko bhi store kar lenge and maximum print kar denge. Sahi approach hai bhaiya
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
yess, u can , lekin isse better ki ek baar iss approcah ko dry run kijiye and then please code karke submit kijiye and fir naya yaha comment karke mujhee v bataa dena aap
@naitikrathore3317
@naitikrathore3317 Жыл бұрын
This guy is very underrated
@tanvisharma6879
@tanvisharma6879 3 жыл бұрын
Homework Done! Can't thank you enough bhaiya:D
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Just spread this channel 😁
@patilashish
@patilashish 2 жыл бұрын
Simple and accepted solution:- func maxDepth(_ root: TreeNode) -> Int { if root == null { return 0 } if root.left == null && root.right == null { return 1 } let maxDepthLeft = maxDepth(root.left) let maxDepthRight = maxDepth(root.right) return max(maxDepthLeft, maxDepthRight) + 1 }
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Waooo amazing
@cr7johnChan
@cr7johnChan 2 жыл бұрын
Aapke graph ki series ke karn yeh khud kar paya hoon . int maxDepth(TreeNode* root) { queueq; if(root==NULL)return 0; int ans=0; TreeNode*temp; q.push(root); while(!q.empty()){ int s=q.size(); while(s!=0){ temp=q.front(); q.pop(); if(temp->left!=NULL){ q.push(temp->left); }if(temp->right!=NULL){ q.push(temp->right); } s--; }ans++; }return ans; }
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
thanks for the support buddy
@alexmercer5870
@alexmercer5870 3 жыл бұрын
Arey Bhai Bhai bhai bhai! Kya mast smjhaate ho bhai❤️ Thanks for being exist🔥
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Thanks brother you exist for listening me
@sudhadevi6692
@sudhadevi6692 Жыл бұрын
I was able to solve it from different approach .. but thanks for this ❤ 📹
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Most welcome 😊
@pranithreddy
@pranithreddy 11 ай бұрын
Bhaiya nice explanation
@HelloWorldbyprince
@HelloWorldbyprince 11 ай бұрын
Thanks a lot
@itsaayush7357
@itsaayush7357 Жыл бұрын
Bhaiya please AAP recursion tree se he recursion ka code btaya karo...usme concept ek dum badiya clear hota he...ese m dande bnakr thoda ajeeb sa lagta h
@maneeshapanu
@maneeshapanu 2 жыл бұрын
sir you explained really well thank you so much. Great explanation.
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
You are most welcome
@AbhishekKumar-de3eo
@AbhishekKumar-de3eo 2 жыл бұрын
Question ko solve krne lga.. Total No. Of node se, leftmost,rightmost se 40 mins nikal gye.. most test fass rhe the After that, I view this full vedio... I was Like, Ekdum inhone wqt bdl diya, jazzbat bdl diye, zindgi bdl di...eh mazak ho rha hai 🥲
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Waooo thanks Abhishek keep learning
@mohitsrivastavaofficial
@mohitsrivastavaofficial 9 ай бұрын
13:10 done.
@gokulnaathb2627
@gokulnaathb2627 3 жыл бұрын
Sir, very nice explanation, thank you so much
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
You are most welcome
@devbhattacharya153
@devbhattacharya153 2 жыл бұрын
Thanks a lot Prince Bhaiya
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
keep learning bhai
@nishabharti1971
@nishabharti1971 3 жыл бұрын
Thanks bhaiya
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Your welcome Nisha Keep learning and sharing my channel with your friends and colleagues
@cr7johnChan
@cr7johnChan 2 жыл бұрын
Done Bhai!!!!Shukriya
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
🤩🤩
@sahiltakwale1937
@sahiltakwale1937 2 жыл бұрын
🙏 Thanks a lot...
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
welcome please please share this channel in your college group
@jayanth1191
@jayanth1191 3 жыл бұрын
Great explanation bro 💥
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Thanks buddy 😊😊
@color2653
@color2653 2 жыл бұрын
Thank you bro😀
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
thanks for the support bro
@AyushGupta-ux4gq
@AyushGupta-ux4gq 3 жыл бұрын
Thanks bro😁😁
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Keep learning buddy
@RN-jo8zt
@RN-jo8zt 9 ай бұрын
definition of height of binary tree is really confusing according to definition Height of Binary tree is the number of edges along the longest path from root to leaf. where leaf node height is 0 . but here it's different and leaf node height is 1. can you pls explain which definition is correct ?
@wantbebigcoder2117
@wantbebigcoder2117 Жыл бұрын
Done
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
👏
@sanjeevgupta2200
@sanjeevgupta2200 2 жыл бұрын
Sir Hume iska iterative solution ni krna haii ?? Ya karna chaiye
@AmanSingh-ph9wg
@AmanSingh-ph9wg Жыл бұрын
done
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
nice
@shivduttjha3502
@shivduttjha3502 3 жыл бұрын
♥️♥️♥️
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Thanks buddy for lots of Love
@jeetkishore7972
@jeetkishore7972 2 жыл бұрын
int depth(node* root ) { static int h = 0; if (root == NULL) { return 0 ; } h++; if (root->left == NULL) { depth(root->right); } else if(root->right){ depth(root->left); } else return -1; return h; }
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
good work dost keep learning
@abhisheksamboddu6580
@abhisheksamboddu6580 2 жыл бұрын
class Solution { public: int h=0; int ans=0; int maxDepth(TreeNode* root) { findans(root); return ans; } void findans(TreeNode* root){ if(root!=NULL){ h++; ans=max(ans,h); findans(root->left); findans(root->right); h--; } } };
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
amazing code work bro keep learning like this
@mdwahid1099
@mdwahid1099 Жыл бұрын
Sir, very nice explanation, thank you so much
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
You are most welcome
@anonymous090
@anonymous090 2 жыл бұрын
Thank you Bhaiya
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
welcome dear
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН
Height of a Binary Tree / Maximum depth of a binary tree Algorithm [REVISITED]
16:50
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 119 М.
Arpit Bhayani talks about real engineering for 1 hour straight
1:16:23
Coding Interviews Be Like
5:31
Nicholas T.
Рет қаралды 6 МЛН