Golang Go easy to follow Union find solution
\n\n\nfunc maxNumEdgesToRemove(n int, edges [][]int) int {\n\n\tvar result int\n\n\tufAlice := NewUnionFind(n)\n\tufBob := NewUnionFind(n)\n\n\tfor _, edge := r
```\n\n\nfunc maxNumEdgesToRemove(n int, edges [][]int) int {\n\n\tvar result int\n\n\tufAlice := NewUnionFind(n)\n\tufBob := NewUnionFind(n)\n\n\tfor _, edge := range edges {\n\t\t// When edge is 3, both Alice and Bob can use it\n\t\t// So we need to union both ufAlice and ufBob\n\t\t// If the union fails, it means that the two nodes are already connected\n\t\tif edge[0] == 3 {\n\t\t\tif !ufAlice.Union(edge[1]-1, edge[2]-1) {\n\t\t\t\t// Counting only once sice Alice and Bob are using the same edges\n\t\t\t\tresult++\n\t\t\t}\n\t\t\tufBob.Union(edge[1]-1, edge[2]-1)\n\t\t}\n\t}\n\n\tfor _, edge := range edges {\n\n\t\t// When edge is 1, only Alice can use it\n\t\tif edge[0] == 1 {\n\t\t\tif !ufAlice.Union(edge[1]-1, edge[2]-1) {\n\t\t\t\tresult++\n\t\t\t}\n\t\t}\n\n\t\t// When edge is 2, only Bob can use it\n\t\tif edge[0] == 2 {\n\t\t\tif !ufBob.Union(edge[1]-1, edge[2]-1) {\n\t\t\t\tresult++\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println("Count:", ufAlice.count, ufBob.count)\n\n\tif ufAlice.count != 1 || ufBob.count != 1 {\n\t\treturn -1\n\t}\n\treturn result\n\n}\n\n// Union Find Data Structure Implementation\ntype UnionFind struct {\n\tparent []int\n\tcount  int\n}\n\nfunc NewUnionFind(num int) *UnionFind {\n\tarr := make([]int, num)\n\tfor i := 0; i < num; i++ {\n\t\tarr[i] = i\n\t}\n\treturn &UnionFind{\n\t\tarr,\n\t\tnum,\n\t}\n}\n\nfunc (u *UnionFind) Union(a, b int) bool {\n\n\tparentA := u.Find(a)\n\tparentB := u.Find(b)\n\tif parentA != parentB {\n\t\tu.parent[parentA] = parentB\n\t\tu.count--\n\t\treturn true\n\t}\n\treturn false\n\n}\n\nfunc (u *UnionFind) Find(a int) int {\n\n\tif u.parent[a] == a {\n\t\treturn a\n\t}\n\tu.parent[a] = u.Find(u.parent[a])\n\treturn u.parent[a]\n}\n```
['Union Find', 'Go']