void makeSet(x) {
arr[x] = x;
}
int find(x) {
while (arr[x] != x) {
x = arr[x];
}
return x;
}
<aside> ℹ️ Кроме того, будем называть путь, который прошёл find(x) как find path.
</aside>
void union(x, y) {
xRoot = find(x);
yRoot = find(y);
// подвешиваем дерево yRoot к xRoot
arr[yRoot] = xRoot;
}