I would like to thank you so much for bringing up such nice intuitive approaches !! You are a true gem! I hope that I could press that like button multiple times !!
Thankyou so much bro, I have used up a whole day to understand this. I have watched this video around 8 times coz I can't able to implement it due to the edge cases w/o referring to your code. Your content is no doubt exceptional, Thanks for that. if(root == null) { if(willPlace) return 1001; return 0; }
why are we considering a case where we allow the parent also and the grand parent of current node also to not have the camera ? we do this for both left and right child and suppose it gives min answer ..wont it be wrong?
"Who can explain it better than Kartik Arora?🤣🤣🤣🤣" . I have not watched the full video yet , but my answer will be : Kartik Arora himself . Btw great job !
15:03, dp( u , 0 , 0 ) than why need of Case 1 and Case2. ( we have to return inf ) As we can see if the current node and parent node have not camera then if we place the camera its child node then the child node can only monitor the current node, not the parent node( no one can monitor) . Anyone can tell me please ?
Time will be order of nlogn ig, only because of the cache ie dp array . We are using map here and not unordered map . We can't use unordered map . Also we can't take a 3d dp because the first parameter is a node and not an integer
great explanation. i missed the case where parent can cover a child,, and so missed that state and couldn't figure out what was wrong..Also can you please explain the greedy solution and first explain why it works... That blew my mind
I think whenever you upload a video, you should mention that somewhere on Codechef Discuss, atleast that's how I found this amazing channel, maybe more people come across your channel this way!
Nice tutorial, Kartik. Just one suggestion. I think the leaf case is not required to be handled. The base case (root == NULL) and the recursion itself handle that scenario. Thanks
if node X is not monitored and X expects one of the child nodes to have a camera but turns out X has no child nodes. Let's say now I call solve(X->left). Then returning a 0 would be incorrect. I should return something that represents it is impossible to cover all the nodes now, given that X is not monitored. Let me know if this clears your doubt.
I completely encourage you to make more videos and work harder. You are doing a great job :), but I felt the problem could be explained a bit simpler. However, your videos are definity great and worth it!!
Dude, the intro is sooo funny 😂😂😂😂 I had to like it
😂
I would like to thank you so much for bringing up such nice intuitive approaches !!
You are a true gem!
I hope that I could press that like button multiple times !!
Thanks Shashank :)
Kaafi cool ban gye aap pehle ek min me😂
Thankyou so much bro, I have used up a whole day to understand this. I have watched this video around 8 times coz I can't able to implement it due to the edge cases w/o referring to your code. Your content is no doubt exceptional, Thanks for that.
if(root == null) {
if(willPlace) return 1001;
return 0;
}
You're welcome and thanks so much for the nice words :)
Keep learning and coding.
Loved the intro!
yes , it got me hooked
Thanks👍 one day every1 will came to know about the precious content of your channel ..
So nice of you
Where were you all these time....spent so much time on this problem already
bhiya ji to maze maze me samjha dete hain aur itni aasani se samjh bhi aa jata hai.cha gye bhiya ji.
like and subscribe zaroor kro bhaiyon
yeh hui na baat, thankss :D
could you explain the last condition dp(u,0,0) for a general tree with more than 2 subtrees(the code)
Intro was legendary
Mastering dp from this channel 🔥
Glad to know man :)
thank you sir , i struggled a lot while solving, you made it easier .
why are we considering a case where we allow the parent also and the grand parent of current node also to not have the camera ? we do this for both left and right child and suppose it gives min answer ..wont it be wrong?
"Who can explain it better than Kartik Arora?🤣🤣🤣🤣" . I have not watched the full video yet , but my answer will be : Kartik Arora himself . Btw great job !
Thanks Sujoy :)
15:03, dp( u , 0 , 0 ) than why need of Case 1 and Case2. ( we have to return inf ) As we can see if the current node and parent node have not camera then if we place the camera its child node then the child node can only monitor the current node, not the parent node( no one can monitor) .
Anyone can tell me please ?
Parent node is monitored by the camera in grandparent node i guess
Time will be order of nlogn ig, only because of the cache ie dp array . We are using map here and not unordered map .
We can't use unordered map .
Also we can't take a 3d dp because the first parameter is a node and not an integer
Give a number to each node. unordered map node*, int.
Then make 3d array for dp.
@@AlgosWithKartik oh yes this idea is great .
Thanks a lot sir .
Sweet and Simple Explaination really loved it
Unable to understand why is there a need of keeping the monitoring state?
great explanation. i missed the case where parent can cover a child,, and so missed that state and couldn't figure out what was wrong..Also can you please explain the greedy solution and first explain why it works... That blew my mind
I think whenever you upload a video, you should mention that somewhere on Codechef Discuss, atleast that's how I found this amazing channel, maybe more people come across your channel this way!
Thanks Parth for the tip and the appreciation :)
Will try to share the videos on relevant platforms.
Nice tutorial, Kartik. Just one suggestion. I think the leaf case is not required to be handled. The base case (root == NULL) and the recursion itself handle that scenario. Thanks
Can you explain your base case when root==NULL ?
Why cant we always return 0?
if node X is not monitored and X expects one of the child nodes to have a camera but turns out X has no child nodes. Let's say now I call solve(X->left).
Then returning a 0 would be incorrect. I should return something that represents it is impossible to cover all the nodes now, given that X is not monitored.
Let me know if this clears your doubt.
if someone write bad about the features or anything , you will work on yourself ( no point of removing that comment )
i love your content btw
This seems like a modified version of knapsack
please explain line sweep and suffix arrays.
God Of DP :)
Thanks Bhuwanesh :)
link is not opening
lol... in the starting of video, all of a sudden i lost my dizziness.
great video sir,please make a video on how to make progress in codeforces contests,what to do if we are not able to solve div2c and div2d problems?
Can we extend this solution to a k-ary tree from this binary tree approach?
yes we definitely can!
Try solving it in O(N) time.
@@AlgosWithKartik thank you bhaiya
I completely encourage you to make more videos and work harder. You are doing a great job :), but I felt the problem could be explained a bit simpler. However, your videos are definity great and worth it!!
Thanks for the appreciation and the feedback :)
Sir please switch on the camera for the whole video... it feels more connecting...hope you understand:)
I do understand. I'll try to set it up properly so I can have the cam on for the entire video
@@AlgosWithKartikyes sir..thank you🙂
can we memoize using 3D vector ??? how we will store TreeNode's address in vector??
Yes we can.
Give a number to each node of the tree.
@@AlgosWithKartik oh, Got it! thanks :)
Can it be done using BFS?
Not sure but I don't think so
super
solution link is not working
I think you need to be logged in to leetcode for accessing that link.
adding ideone link in description instead.
@@AlgosWithKartik logged in but not working btw i understand the solution thanks (y)
can anyone explain line 34?
Another great video.
Great
Great video 🔥
thankyou sir :D
happy to see how similar my code is to yours xD...
Uniteresting problem xdddddddddddd