Count the number of uni-value subtrees (all nodes have the same value) in a binary tree.
Given the root of a binary tree, count the number of subtrees where all nodes have the same value. A subtree is defined as any node and all its descendants.
Examples
Input:[5,1,5,5,5,null,5]
Output:4
Input:[null]
Output:0
Hints
Use DFS post-order: check if a subtree is uni-value from bottom up.
Return both the count and whether the current subtree is uni-value.
If current node value equals children's values (or no children), it's uni-value.