My Python Solution


  • 0
    B
    class Solution(object):
    def isSameTree(self, p, q):
        if p and q:
            if p.val == q.val:
                return (bool)(self.isSameTree(p.left, q.left)*self.isSameTree(p.right, q.right))
            else:
                return False
        if not p and not q:
            return True
        else:
            return False

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.