看板 Marginalman
直接硬幹下去 好爽喔== 對不起 一二三四五 def flipEquiv(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool: ans = True def dfs(r1, r2): if r1 is None and r2 is None: return True elif (r1 is None and r2 is not None) or (r1 is not None and r2 is None) or r1.val!=r2.val: return False else: return (dfs(r1.left,r2.left) and dfs(r1.right, r2.right)) or (dfs(r1.left, r2.right) and dfs(r1.right, r2.left)) return dfs(root1, root2) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1729783976.A.5A1.html