MCPcopy Create free account
hub / github.com/ByteByteGoHq/coding-interview-patterns / find

Method find

kotlin/Graphs/MergingCommunities.kt:24–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 }
23
24 fun find(x: Int): Int {
25 if (x == parent[x]) {
26 return x
27 }
28 // Path compression.
29 parent[x] = find(parent[x])
30 return parent[x]
31 }
32
33 fun getSize(x: Int): Int {
34 return size[find(x)]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected