Short Palindrome Discussions | Algorithms | HackerRank
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.
Try counting the children. If the subtree has even number of nodes then the edge leading to this subtree can be removed. Otherwise, you have to keep on searching until you find a suitable edge or the entire tree exhausted. As it always can be decomposed into forests of even number of nodes, you will always end up with an answer greater than 1.
Short Palindrome
You are viewing a single comment's thread. Return to all comments →
Try counting the children. If the subtree has even number of nodes then the edge leading to this subtree can be removed. Otherwise, you have to keep on searching until you find a suitable edge or the entire tree exhausted. As it always can be decomposed into forests of even number of nodes, you will always end up with an answer greater than 1.