A binary tree is uni-valued when every node in it holds the same value. Given the root of a binary tree, return true if the tree is uni-valued and false otherwise.
A binary tree is uni-valued when every node in it holds the same value. Given the root of a binary tree, return true if the tree is uni-valued and false otherwise.
Example 1:
Input: {"root":[1,1,1,1,1,null,1]}
Output: true
Constraints:
The number of nodes in the tree is in the range [1,100].
0≤Node.val<100
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"root":[1,1,1,1,1,null,1]}
The root holds 1, so every node must equal 1. Push the root onto the stack.