Search⌘ K
AI Features

Solution: Univalued Binary Tree

Solution: Univalued Binary Tree gives you the root of a binary tree. Return true when every node has the same value, and false when any node differs.

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

  • 0≤0 \leq ...