Short Palindrome Discussions | Algorithms | HackerRank

Short Palindrome

  • + 18 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.