Search⌘ K
AI Features

Solution: Univalued Binary Tree

Explore how to verify whether a binary tree is uni-valued by applying depth-first search. This lesson teaches you to compare parent and children node values recursively, understand the solution's logic, and consider its time and space complexity.

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 ...