推 JIWP: 別捲了 06/26 00:27
馬的
不知道為啥覺得整個陰陽怪氣
超卡
可能太晚了==
晚安
def bstToGst(self, root: TreeNode) -> TreeNode:
def dfs(root: TreeNode, summ) -> int:
if root is None:
return summ
right = dfs(root.right, summ)
root.val += right
left = dfs(root.left, root.val)
return left
dfs(root, 0)
return root
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.76.3.7 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1719332793.A.77F.html