摘要:
并查集模板 # # ==> 并查集模板(附优化) # author: Geek0070@blog.geek007.top class UnionFind(): def __init__(self): self.roots = {} self.setCnt = 0 # 连通分量的个数 # Union优 阅读全文

posted @ 2025-05-28 15:19
Geek0070
阅读(53)
评论(0)
推荐(0)
摘要:
1.题目基本信息 1.1.题目描述 你有一个包含 n 个节点的图。给定一个整数 n 和一个数组 edges ,其中 edges[i] = [ai, bi] 表示图中 ai 和 bi 之间有一条边。 返回 图中已连接分量的数目 。 1.2.题目地址 https://leetcode.cn/proble 阅读全文
posted @ 2025-05-28 09:16
Geek0070
阅读(37)
评论(0)
推荐(0)