Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
381 B
1
Indexable
Never
#
class Solution(object):
    def isSameTree(self, p, q):
        """
        :type p: TreeNode
        :type q: TreeNode
        :rtype: bool
        """
        def isSame(n1, n2):
            if n1 and n2:
                return n1.val == n2.val and isSame(n1.left, n2.left) and isSame(n1.right, n2.right)
            return n1 is None and n2 is None
        return isSame(p, q)
Leave a Comment