Practice Univalued Binary Tree
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A binary tree is uni-valued if every node in the tree has the same value. Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise.
Source: Univalued Binary Tree on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
root = [1,1,1,1,1,null,1]
Output
true
# Example 2
Input
root = [2,2,2,5,2]
Output
false
Constraints
The number of nodes in the tree is in the range [1, 100].
0 <= Node.val < 100
Related LeetCode Problems
Practice more problems similar to Univalued Binary Tree.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.