Here is the interview question prompt, presented for reference.
Can you count all the univalued subtrees
in a binary tree, as shown in the figure below?
We are given a binary tree. The challenge is to count all the univalued subtrees in the tree. Just to recall, a subtree
is any node along with its descendants. The root and all its descendants form the entire tree. A univalued subtree is therefore a subtree in which all the nodes have the same keys. The figure below shows all the univalued subtrees of the binary tree of the previous figure.
You can see the full challenge with visuals at this link.
Challenges • Asked over 6 years ago by Jake from AlgoDaily
This is the main discussion thread generated for Counting Univalued Subtrees.