A sacred grove in Codetikki is a binary tree where every node has a value. A subtree is called "unival" if all its nodes share the same value. Count the number of unival subtrees in a given binary tree. Input: a binary tree given in level-order as space-separated values, with "null" for absent nodes. Output: the count of unival subtrees.
Example 1:
Example 2:
Constraints:
1 <= number of nodes <= 10^4 Node values are single lowercase letters or null
Tags:
