Implement a method to check if a tree is unival
Anonymous
def unival(root): if not root: return True if root.left and root.val != root.left.val: return False if root.right and root.val != root.right.val: return False return unival(root.left) and unival(root.right)
Check out your Company Bowl for anonymous work chats.