随笔分类 -  并查集

摘要:problem:https://leetcode.com/problems/longest-consecutive-sequence/ 使用并查集,时间不是严格的O(n) 阅读全文
posted @ 2019-08-06 12:44 fish1996 阅读(227) 评论(0) 推荐(0)
摘要:problem:https://leetcode.com/problems/similar-string-groups/ 此题是最普通的并查集,没有什么变化,但有卡数据点的地方,所以需要使用优化过的并查集,此处使用的方法是把元素个数较少的集合作为子节点合并到较大的集合上,避免出现较长的分支。 阅读全文
posted @ 2019-07-28 17:06 fish1996 阅读(227) 评论(0) 推荐(0)