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

Method find

java/Graphs/MergingCommunities.java:34–41  ·  view source on GitHub ↗
(int x)

Source from the content-addressed store, hash-verified

32 }
33
34 public int find(int x) {
35 if (x == this.parent[x]) {
36 return x;
37 }
38 // Path compression.
39 this.parent[x] = find(this.parent[x]);
40 return this.parent[x];
41 }
42
43 public int getSize(int x) {
44 return this.size[find(x)];

Callers 2

unionMethod · 0.95
getSizeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected