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

Method UnionFind

cpp/Graphs/connect_the_dots.cpp:10–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 std::vector<int> parent;
9 std::vector<int> size;
10 UnionFind(int size) {
11 parent.resize(size);
12 this->size.resize(size, 1);
13 for (int i = 0; i < size; i++) {
14 parent[i] = i;
15 }
16 }
17
18 bool unionSets(int x, int y) {
19 int repX = findSet(x);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected