0250. Count Univalue Subtrees

https://leetcode.com/problems/count-univalue-subtrees

Description

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

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

Example 1:

Example 2:

Example 3:

Constraints:

  • The numbrt of the node in the tree will be in the range [0, 1000].

  • -1000 <= Node.val <= 1000

ac

Last updated

Was this helpful?