Python Recursive Solution


  • 0
    J

    class Solution(object):

    def isSymmetric(self, root):
        if root is None:
            return True
        else:
            return self.compare(root.left,root.right)
    
    
    def compare(self,l,r):
        if l and r:
            return l.val == r.val and self.compare(l.left,r.right) and self.compare(l.right,r.left)
        else:
            return l is r

Log in to reply
 

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