Re: [閒聊] 每日leetcode已回收

看板Marginalman作者 (通通打死)時間1年前 (2024/07/17 10:43), 1年前編輯推噓2(200)
留言2則, 2人參與, 1年前最新討論串512/1554 (看更多)
肥肥今天又翹班打code了 希望老闆不要把我sa了 def delNodes(self, root: Optional[TreeNode], to_delete: List[int]) -> List[TreeNode]: ans = [] if root.val not in to_delete: ans.append(root) def dfs(root): nonlocal ans if root is None: return root root.right = dfs(root.right) root.left = dfs(root.left) delete_cur = root.val in to_delete if delete_cur: if root.left: ans.append(root.left) if root.right: ans.append(root.right) return None if delete_cur else root dfs(root) return ans -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1721184192.A.6F2.html ※ 編輯: DJYOMIYAHINA (125.229.37.69 臺灣), 07/17/2024 10:43:24

07/17 10:43, 1年前 , 1F
幫內推
07/17 10:43, 1F

07/17 10:46, 1年前 , 2F
要去咕咕嚕了
07/17 10:46, 2F
文章代碼(AID): #1cbo_0Ro (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1cbo_0Ro (Marginalman)