We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 97feab7 + 95740e9 commit 9083ce3Copy full SHA for 9083ce3
Contents/07.Tree/05.Union-Find/01.Union-Find.md
@@ -251,7 +251,7 @@ class UnionFind:
251
self.fa[root_y] = root_x # y 的根节点连接到 x 的根节点上,成为 x 的根节点的子节点
252
else: # x 的根节点对应的树的深度 等于 y 的根节点对应的树的深度
253
self.fa[root_x] = root_y # 向任意一方合并即可
254
- rank[y] += 1 # 因为层数相同,被合并的树必然层数会 +1
+ rank[root_y] += 1 # 因为层数相同,被合并的树必然层数会 +1
255
return True
256
257
def is_connected(self, x, y): # 查询操作:判断 x 和 y 是否同属于一个集合
0 commit comments