thanks bro…nice trick
In which type of question this trick is applied?
Any more question where this trick is used so that We can understand more clearly
thanks for sharing this trick.
Basically ulta bfs karke you calculate the sum? Kya mai theek samjha?
Yes, right .
And about problems, I have used it at too many places, 1-hard problem from August-Long, 3rd problem of round-E Google-Kickstart,4th problem of recent Div2-contest(Numbers on tree). Many variations on this technique are possible which can make one fall in love with it.
can you provide links to some questions for dp on trees
Can you provide 1-2 ques and link of your solution…for better understanding…
There’s a blog on Codeforces about it, I recommend you read that for more problems on dp on trees.
Can you please share your code for this approach
@ anon55659401
what if tree is like this?
node: 2 and node: 3 will have 0
hence node 1 = 0.
Though my first approach was this itself but getting WA.