Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 1.27 KB

File metadata and controls

64 lines (40 loc) · 1.27 KB

中文文档

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:

Input: root = [5,1,5,5,5,null,5]
Output: 4

Example 2:

Input: root = []
Output: 0

Example 3:

Input: root = [5,5,5,5,5,null,5]
Output: 6

 

Constraints:

  • The numbrt of the node in the tree will be in the range [0, 1000].
  • -1000 <= Node.val <= 1000

Solutions

Python3

Java

...