Untitled

 avatar
unknown
plain_text
a year ago
381 B
4
Indexable
#
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)
Editor is loading...
Leave a Comment