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.
Assuming that the edges are undirected, Sample test case's output should be 3 and 3. Because if you consider the tree rooted at 2, it will have 3 children; 1, 3, 4.
I think I am missing something here. Can you someone please explain how the answer is 2 and not 3 for the second query?
Thanks
Salil
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Coloring Tree
You are viewing a single comment's thread. Return to all comments →
Assuming that the edges are undirected, Sample test case's output should be 3 and 3. Because if you consider the tree rooted at 2, it will have 3 children; 1, 3, 4.
I think I am missing something here. Can you someone please explain how the answer is 2 and not 3 for the second query?
Thanks
Salil