Tap here to switch tabs
Problem
Ask
Submissions

Problem: Univalued Binary Tree

med
30 min
Explore how to identify a univalued binary tree by verifying that all nodes contain the same value. This lesson guides you through implementing a depth-first search to return true if the tree is univalued, and false otherwise, helping you tackle related coding interview problems efficiently.

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 Node.data <100< 100

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Univalued Binary Tree

med
30 min
Explore how to identify a univalued binary tree by verifying that all nodes contain the same value. This lesson guides you through implementing a depth-first search to return true if the tree is univalued, and false otherwise, helping you tackle related coding interview problems efficiently.

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 Node.data <100< 100