# Question

Formatted question description: https://leetcode.ca/all/250.html

 250	Count Univalue Subtrees

Given a binary tree, count the number of uni-value subtrees.

A Uni-value subtree means all nodes of the subtree have the same value.

For example:
Given binary tree,

5
/ \
1   5
/ \   \
5   5   5

return 4.
3 leaf nodes
1 subtree 5-5 of right

@tag-tree



# Algorithm

Check from bottom to top, using post-order traversal order, left and right roots, we still call the function recursively,

For the currently traversed node, if the function is called recursively on the left and right child nodes, and the return is true,

Then it means that the value of the current node and the value of the left and right subtrees are the same, then there is another tree, so the result is incremented by 1.

Java