Skip to content

Commit

Permalink
Merge pull request itcharge#1 from ZhiyaoWen999/ZhiyaoWen999-patch-1
Browse files Browse the repository at this point in the history
Update 01.Union-Find.md
  • Loading branch information
ZhiyaoWen999 committed Dec 11, 2023
2 parents 41b4368 + 030dcca commit 7a1009a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Contents/07.Tree/05.Union-Find/01.Union-Find.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class UnionFind:

if self.rank[root_x] < self.rank[root_y]: # x 的根节点对应的树的深度 小于 y 的根节点对应的树的深度
self.fa[root_x] = root_y # x 的根节点连接到 y 的根节点上,成为 y 的根节点的子节点
elif self.rank[root_y] > self.rank[root_y]: # x 的根节点对应的树的深度 大于 y 的根节点对应的树的深度
elif self.rank[root_x] > self.rank[root_y]: # x 的根节点对应的树的深度 大于 y 的根节点对应的树的深度
self.fa[root_y] = root_x # y 的根节点连接到 x 的根节点上,成为 x 的根节点的子节点
else: # x 的根节点对应的树的深度 等于 y 的根节点对应的树的深度
self.fa[root_x] = root_y # 向任意一方合并即可
Expand Down Expand Up @@ -544,4 +544,4 @@ class Solution:
- 【书籍】算法训练营 - 陈小玉 著
- 【书籍】算法 第 4 版 - 谢路云 译
- 【书籍】算法竞赛进阶指南 - 李煜东 著
- 【书籍】算法竞赛入门经典:训练指南 - 刘汝佳,陈锋 著
- 【书籍】算法竞赛入门经典:训练指南 - 刘汝佳,陈锋 著

0 comments on commit 7a1009a

Please sign in to comment.