We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Calculate the diameter of the tree (longest path between the nodes), this vertices are those which we visit only once and rest vertices we visit twice.
Answer = weight of diameter + (totalTree weight - weight of Diameter)*2
Jeanie's Route
You are viewing a single comment's thread. Return to all comments →
Here is my java solution