Skip to content

Commit 9083ce3

Browse files
authored
Merge pull request #146 from wangxinalex/patch-2
Update 01.Union-Find.md
2 parents 97feab7 + 95740e9 commit 9083ce3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Contents/07.Tree/05.Union-Find/01.Union-Find.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class UnionFind:
251251
self.fa[root_y] = root_x # y 的根节点连接到 x 的根节点上,成为 x 的根节点的子节点
252252
else: # x 的根节点对应的树的深度 等于 y 的根节点对应的树的深度
253253
self.fa[root_x] = root_y # 向任意一方合并即可
254-
rank[y] += 1 # 因为层数相同,被合并的树必然层数会 +1
254+
rank[root_y] += 1 # 因为层数相同,被合并的树必然层数会 +1
255255
return True
256256

257257
def is_connected(self, x, y): # 查询操作:判断 x 和 y 是否同属于一个集合

0 commit comments

Comments
 (0)