We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8fc7384 commit 1b13dc4Copy full SHA for 1b13dc4
965_univalued_binary_tree.scala
@@ -0,0 +1,6 @@
1
+object Solution {
2
+ def isUnivalTree(root: TreeNode, value: Int = -1): Boolean = {
3
+ if (root == null) true
4
+ else (if (value >= 0) (value == root.value) else true) && isUnivalTree(root.left, root.value) && isUnivalTree(root.right, root.value)
5
+ }
6
+}
0 commit comments