Python recursive solution

  • 2
        def check_symmetry(self, node1, node2):
            if not node1 and not node2:
                return True
            elif not node1 or not node2:
                return False
            return (node1.val == node2.val and 
                self.check_symmetry(node1.left, node2.right) and
                self.check_symmetry(node1.right, node2.left))

  • 0
    This post is deleted!

Log in to reply

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