leetcode101 對稱二叉樹
阿新 • • 發佈:2018-12-16
def isSymmetric(self, root): if root is None: return True return self.help(root.left, root.right) def help(self, left, right): ’‘’ 終止條件是左子樹和右子樹是葉子節點的時候 ‘’‘ if not left and not right: return True if not left: return False if not right: return False if left.val != right.val: return False return self.help(left.left, right.right) and self.help(right.left, left.right)