93: Count univalue subtrees
Given a binary tree
, return the number
of uni-value subtrees
Note: uni-value means all subtree nodes have the same value
Example 1
Input: 1
/ \
2 3
Output: 2
Explanation:
2
and3
have the same left and right subtrees
Example 2
Input: 1
/ \
1 1
Output: 3