美文网首页
100 Same Tree

100 Same Tree

作者: Closears | 来源:发表于2015-06-16 16:08 被阅读9次

    原题链接:Same Tree

    class Solution:
        # @param {TreeNode} p
        # @param {TreeNode} q
        # @return {boolean}
        def isSameTree(self, p, q):
            if p is None and q is None:
                return True
            elif p is None or q is None:
                return False
            else:
                if p.val == q.val:
                    return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right)
                return False

    相关文章

      网友评论

          本文标题:100 Same Tree

          本文链接:https://www.haomeiwen.com/subject/rrksqttx.html