Univalue Tree is an example of Tree problems. In this post we will see how we can solve in Javascript.

Problem Description

Given a binary tree, check if it's uni-value tree. A Uni-value tree means all nodes of the tree have the same value.

For example: Given binary tree,


         / \

        5   5

       / \   \

      5   5   5

return true.

Please check the main.js snippet for the solution.

If you have different approach in mind or have any suggestion for this implementation feel free to share in the comment below. Thanks!