Univalued Binary Tree

class Solution(object):
    def isUnivalTree(self, root):
        if root == None:
        	return True
        if self.Methon(root, root.val) == True:
        	return False
        return True
    def Methon(self, root, val):
        if root == None:
        	return False
        if root.val == None:
        	return False
        if root.val != val:
        	return True
        return self.Methon(root.left, val) or self.Methon(root.right, val)

猜你喜欢

转载自blog.csdn.net/m0_37770463/article/details/88790246