Count Univalue Subtrees

Given the root of a binary tree, count the number of uni-value subtrees. A uni-value subtree is a subtree, meaning one node together with all of its descendants, in which every node has the same value. A leaf always counts as a uni-value subtree.

Examples
Input: [0]
Output: 1
Hints
Related Problems

Count Univalue Subtrees

Given the root of a binary tree, count the number of uni-value subtrees. A uni-value subtree is a subtree, meaning one node together with all of its descendants, in which every node has the same value. A leaf always counts as a uni-value subtree.