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

Method UnionFind

java/Graphs/ConnectTheDots.java:10–17  ·  view source on GitHub ↗
(int size)

Source from the content-addressed store, hash-verified

8 int[] size;
9
10 public UnionFind(int size) {
11 this.parent = new int[size];
12 this.size = new int[size];
13 for (int i = 0; i < size; i++) {
14 this.parent[i] = i;
15 }
16 Arrays.fill(this.size, 1);
17 }
18
19 public boolean union(int x, int y) {
20 int repX = find(x);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected