We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0785f30 commit 8c00e98Copy full SHA for 8c00e98
graph/unionfind.go
@@ -34,7 +34,7 @@ func NewUnionFind(s int) UnionFind {
34
35
// Find finds the root of the set to which the given element belongs.
36
// It performs path compression to make future Find operations faster.
37
-func (u UnionFind) Find(q int) int {
+func (u *UnionFind) Find(q int) int {
38
if q != u.parent[q] {
39
u.parent[q] = u.Find(u.parent[q])
40
}
@@ -43,7 +43,7 @@ func (u UnionFind) Find(q int) int {
43
44
// Union merges the sets, if not already merged, to which the given elements belong.
45
// It performs union by rank to keep the tree as flat as possible.
46
-func (u UnionFind) Union(p, q int) {
+func (u *UnionFind) Union(p, q int) {
47
rootP := u.Find(p)
48
rootQ := u.Find(q)
49
0 commit comments