Search⌘ K
AI Features

Solution: Univalued Binary Tree

Understand how to verify if every node in a binary tree shares the same value using a depth-first search approach. Explore a recursive method that compares parent and child nodes, helping you solve uni-valued tree problems with clear time and space complexity analysis.

Statement

A binary tree is considered uni-valued if every node in the tree contains the same value.

Given the root of a binary tree, return TRUE if the tree is uni-valued, or FALSE otherwise.

Constraints:

  • The number of nodes in the tree is in the range [1,100][1, 100].

  • 00 \leq ...