Go golang clean solution
Runtime: 300 ms, faster than 50.00% of Go online submissions for Largest Component Size by Common Factor.\nMemory Usage: 8.6 MB, less than 50.00% of Go online s
>Runtime: 300 ms, faster than 50.00% of Go online submissions for Largest Component Size by Common Factor.\nMemory Usage: 8.6 MB, less than 50.00% of Go online submissions for Largest Component Size by Common Factor.\n\n```go\ntype DSU struct {\n    parent []int\n}\n\nfunc (d *DSU) find(x int) int {\n    if d.parent[x] != x { d.parent[x] = d.find(d.parent[x]) }\n    return d.parent[x]\n}\n\nfunc (d *DSU) union(x, y int) {\n    d.parent[d.find(x)] = d.parent[d.find(y)]\n}\n\nfunc Constructor(n int) *DSU {\n    s := make([]int, n)\n    for i := 0; i < n; i++ { s[i] = i }\n    return &DSU{ s }\n}\n\nfunc largestComponentSize(A []int) int {\n    ans, max, cache := 1, 0, make(map[int]int)\n    for _, a := range A { if a > max { max = a } }\n    DSU := Constructor(max + 1)\n    for _, a := range A {\n        for k := 2; k <= int(math.Sqrt(float64(a))); k++ {\n            if a % k == 0 {\n                DSU.union(a, k)\n                DSU.union(a, a / k)\n            }\n        }\n    }\n    for _, a := range A {\n        r := DSU.find(a)\n        cache[r]++\n        if cache[r] > ans { ans = cache[r] }\n    }\n    return ans\n}\n```
[]