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.
What is wrong with this approach.
First I applied dfs two times to get the maximum diameter and the path of the maximum diameter. Coloring all these node occuring in maximum diameter path with black color, I applied dfs for these nodes getting the maximum length starting from this node not including the black nodes. then adding the maximum distance obtained by applying dfs two time and the maximum distance obtained from these black nodes.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximal Tree Diameter
You are viewing a single comment's thread. Return to all comments →
What is wrong with this approach. First I applied dfs two times to get the maximum diameter and the path of the maximum diameter. Coloring all these node occuring in maximum diameter path with black color, I applied dfs for these nodes getting the maximum length starting from this node not including the black nodes. then adding the maximum distance obtained by applying dfs two time and the maximum distance obtained from these black nodes.