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.
Ok
HackerRank
|
Prepare
Certify
Compete
Apply
Hiring developers?
Log In
Sign Up
Prepare
Algorithms
Graph Theory
Even Tree
Discussions
Even Tree
Problem
Submissions
Leaderboard
Discussions
Editorial
You are viewing a single comment's thread.
Return to all comments →
fernando_pires
8 years ago
+ 13 comments
I have solved it this way:
Determine the bottom nodes of the tree (with no children)
Assign "weight" 1 to each of the bottom nodes
Build your way up the tree calculating the "weight" of each node (for example a node with 2 children has "weight" 3)
Count the number of nodes with even "weight" excluding the root. That's your answer...
View more Comments..
Even Tree
You are viewing a single comment's thread. Return to all comments →
I have solved it this way: