討論串[閒聊] 每日leetcode
共 1554 篇文章
內容預覽:
1233. Remove Sub-Folders from the Filesystem. ## 思路. 把folder都丟到Trie tree 並記錄是否為目錄尾 (is_end). 掃Trie tree時檢查is_end. ## Code. ```python. class TrieNode:.
(還有981個字)
內容預覽:
https://leetcode.com/problems/remove-sub-folders-from-the-filesystem. 1233. Remove Sub-Folders from the Filesystem. 給一個資料夾列表 folder 把裡面的子資料夾刪除後回傳 可以以任
(還有1388個字)
內容預覽:
1462. course schedule iv. 昨天想說複習一下拓樸拉ㄐ獸. 發現課程表竟然有4就寫ㄌ. 簡單來說就是給你修課順序. 判斷a課是不是b課的先修課程. ##. 沒cycle所以是dag. 做adj list. 找source (indegree = 0. 做一個reachable
(還有1172個字)
內容預覽:
951.. 這種數字小於1000的都好舒服. 簡單直接. value判斷一下. 進去跑dfs. 左左右右 或是 左右右左. 按快一點可以接上上下下BA. class Solution {. public:. bool flipEquiv(TreeNode* r1, TreeNode* r2) {.
(還有400個字)
內容預覽:
直接硬幹下去. 好爽喔==. 對不起. 一二三四五. def flipEquiv(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) ->bool:. def dfs(r1, r2):. if r1 is None and r2 i
(還有305個字)