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.
- Prepare
- Java
- Advanced
- Java Visitor Pattern
- Discussions
Java Visitor Pattern
Java Visitor Pattern
Sort by
recency
|
169 Discussions
|
Please Login in order to post a comment
Only the test-0 has legitimate edges. The rest of the tests are junk. Don't worry about solving the rest because of "Junk" edges that will not construct the tree properly. :-(
Complete solution in this website for this question.Java Visitor Pattern- Duplicate Words-hacker-rank-solution
(https://digitwood.com/java-visitor-pattern-hacker-rank-solution-digit-wood/)
Complete solution in this website for this question.Java Visitor Pattern- Duplicate Words-hacker-rank-solution
(https://digitwood.com/java-visitor-pattern-hacker-rank-solution-digit-wood/)
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.
Hello, IMHO test-case 1 (at least, I did not continued my analysis) is bad. A tree is a DAG, meaning Directed Acyclic Graph and each node must have exactly one parent. So, I assumed edges are directed from left to right (because the root node 1 is on the left) Node 2 is not reachable from any other, knowing that node 1 is the root, as specified. Node 4 has two parents: 1 and 2 because it gives edges: 1 4 and 2 4. So I abandon solving this ...
https://en.wikipedia.org/wikTree_%28data_structure%29#Terminologies_used_in_Trees