Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    965 - Univalued Binary Tree\.

    Easy

    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.

    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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Boolean isUnivalTree(TreeNode root)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait