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.
Yup, wouldn't bother with this one unless they update the problem statement. u,v are not parent, child (as they would be in any rational world). Choosing the u or v not already in the tree as your child will get you some way. But you will still need to figure out how to ignore all the trees that are not connected to the root. At the end of the day, this problem is 5% to do with the Visitor pattern and 95% to do with guessing how to build the tree from a poor specification. I'm so frustrated with it I'm walking away. It's also pure sadism that the test cases that expose these issues are hidden, and use hundreds of lines of data.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Visitor Pattern
You are viewing a single comment's thread. Return to all comments →
Yup, wouldn't bother with this one unless they update the problem statement. u,v are not parent, child (as they would be in any rational world). Choosing the u or v not already in the tree as your child will get you some way. But you will still need to figure out how to ignore all the trees that are not connected to the root. At the end of the day, this problem is 5% to do with the Visitor pattern and 95% to do with guessing how to build the tree from a poor specification. I'm so frustrated with it I'm walking away. It's also pure sadism that the test cases that expose these issues are hidden, and use hundreds of lines of data.