leetcood学习笔记-965-单值二叉树

题目描述;

leetcood学习笔记-965-单值二叉树

第一次提交;

class Solution:
    def isUnivalTree(self, root: TreeNode) -> bool:
        if root == None:
            return  True
        if root.left!=None and root.left.val!=root.val:
            return False
        if root.right!=None and root.right.val != root.val:
            return False
        if self.isUnivalTree(root.left) and self.isUnivalTree(root.right):
            return True
        else:
            return False

 

上一篇:FindGLEW.cmake找不到


下一篇:LeetCode 965. Univalued Binary Tree