mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
debug
This commit is contained in:
@ -131,7 +131,9 @@ private:
|
|||||||
}
|
}
|
||||||
// 将v->u 这条边加入并查集
|
// 将v->u 这条边加入并查集
|
||||||
void join(int u, int v) {
|
void join(int u, int v) {
|
||||||
if (isSame(u, v)) return ;
|
u = find(u); // 寻找u的根
|
||||||
|
v = find(v); // 寻找v的根
|
||||||
|
if (u == v) return ; // 如果发现根相同,则说明在一个集合,不用两个节点相连直接返回
|
||||||
father[v] = u;
|
father[v] = u;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user