I think there should be one more if condition i.e when from both left and right child gives "ok" then node should itself provide vaccine . Please correct me.
In the Question, it's given that the input tree is a binary tree but in some of your examples you had taken a tree with node having more than 2 children, but the overall explanation and solution was really awesome !! Nice Approach ..
Pranshu both are still binary trees , maybe it created confusion because I wrote it that way, For example at 3:11 the tree is: 5 1 3 2 4 And on 17 :50 the tree is 6 3 2 4 1 5
Time Complexity -> O(N)
int novaccines = 0;
int supplyVaccine(Node* root){
// Your code goes here
if(vaccine(root)=="want")
novaccines++;
return novaccines;
}
string vaccine(Node* root)
{
if(root==NULL)
return "ok";
string left =vaccine(root->left);
string right =vaccine(root->right);
if(left=="want" || right =="want")
{
novaccines++;
return "provide";
}
else if(left=="provide" || right =="provide")
return "ok";
return "want";
}
it is greedy right?
Crystal clear explanation👌
great explanation!
Amazing explanation! Great work.
I like the way you do coding
Super Smart Coder 🌟 :)
"Please add POP filter with mic" -- suggestions
Because the pop pop air sound is disturbing...
I think there should be one more if condition i.e when from both left and right child gives "ok" then node should itself provide vaccine . Please correct me.
quite a fresh and unique take on question
nicely explained by you keep it up
Why the same code is not executing in Java? And serious issues?
Mind blowing dude . Hats off. Breaked all the limits
Thank you so much
thanks a lot for such an awesome explanation
Thank you ❤️
Ahhh amazing and very gracefully explained. After this go and try out leetcode binary tree camera 📷
Thanks, both are actually same problems :)
@@probabilitycodingisfunis1 Han didi, bakiyon ke liye practice ho jayegi
Amazing , Thank you for making videos ... ur videos are very helpful
Thank you
Thank you !very nicely explained.
Watching ur first video and u just nailed it...way u return string is 👌
In the Question, it's given that the input tree is a binary tree but in some of your examples you had taken a tree with node having more than 2 children, but the overall explanation and solution was really awesome !! Nice Approach ..
Thanks, I have not taken tree with node more than 2 children, all are binary tree examples , can you point out where there is confusion?
@@probabilitycodingisfunis1 at 3:11 , 17:50 although not a big issue, you just took those examples to explain your intuition. ✌️✌️
Pranshu both are still binary trees , maybe it created confusion because I wrote it that way,
For example at 3:11 the tree is:
5
1
3 2
4
And on 17 :50 the tree is
6
3
2 4
1 5
OP didi 🔥🔥🔥🔥🔥🔥
+1
Thank you so much
Good explanation.👍
Thanks
Amazing explanation
Thank you
Explanation is Awesome but please do discuss about the complexity( Space and Time )....Thanks.
Its O(N), you are just doing a traversal, thanks for the suggestion
Watching this again forgot how did i approached it :\
good explanation😊
Thank you
This is more intuitive than using a map.
Awesome explanation 😄
Thanks
can you upload solution of the leetcode problem "1675. Minimize Deviation in Array"?
Hey, please make a video on Maximum Width of Binary Tree, lc662
Awesome explanation!
Thanks
Great Explanation, Keep up the good work and contribution to this community.
Thanks
Almost cried in the last case 😭
Niceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee