Help in a question with Tree DP

Revision en1, by blinkshot, 2019-09-13 15:21:55

I got stuck in this question . This is the question — "You are given a tree consisting of n nodes. Your task is to determine for each node the sum of the distances from the node to all other nodes."

Any help in understanding how to apply dp here will be much appreciated.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English blinkshot 2019-09-13 15:21:55 351 Initial revision (published)