Re: [閒聊] 每日leetcode
直接硬幹下去
好爽喔==
對不起
一二三四五
def flipEquiv(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) ->
bool:
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
※ 編輯: DJYOMIYAHINA (125.229.37.69 臺灣), 10/24/2024 23:35:23
→
10/24 23:35,
1年前
, 1F
10/24 23:35, 1F
→
10/24 23:35,
1年前
, 2F
10/24 23:35, 2F
→
10/24 23:40,
1年前
, 3F
10/24 23:40, 3F
推
10/24 23:47,
1年前
, 4F
10/24 23:47, 4F
討論串 (同標題文章)
完整討論串 (本文為第 1040 之 1548 篇):