討論串[閒聊] 每日leetcode
共 1552 篇文章
內容預覽:
2948. Make Lexicographically Smallest Array by Swapping Elements. 思路:. 建立一個idx矩陣:idx[i]=[i]. 接著把idx跟nums按照nums的大小排序. 再來就是去判斷. 如果nums[i]-nums[i-1]<=lim
(還有887個字)
內容預覽:
2948. Make Lexicographically Smallest Array by Swapping Elements. ## 思路. 先產生排序過的 {num, idx}. 用UnionFind把可以互換的idx都加到同group. ## Code. ```cpp. class Unio
(還有1482個字)
內容預覽:
802. Find Eventual Safe States. 思路:. 首先先記錄terminal_point. 所有都terminal_point都是safe_point. 接著就dfs下去. 如果i以後的路徑都能到safe_point. 那i就是safe_point. 就把i記錄下來,並且記錄
(還有1408個字)
內容預覽:
在下幾百年沒寫DFS了. 狗屎一般的寫法. 早用拓ㄆ排序. def eventualSafeNodes(self, graph: List[List[int]]) -> List[int]:. n = len(graph). flag = [1 if len(graph[i])==0 else 0
(還有585個字)
內容預覽:
802.. 拓撲拉機獸. 嗎?. class Solution {. public:. vector<int> eventualSafeNodes(vector<vector<int>>& graph) {. int n = graph.size();. vector<vector<int>> ad
(還有700個字)