a few solutions
For each number x in the input array A, use an associative array m to map factors of x to x.  There are 3 use cases to consider for each factor of x:\n\n Case 1
For each number `x` in the input array `A`, use an associative array `m` to map factors of `x` to `x`.  There are 3 use cases to consider for each factor of `x`:\n\n* **Case 1:** `x` as a factor of itself\n* **Case 2:** the i<sup>th</sup> factor of `x`\n* **Case 3:** the j<sup>th</sup> factor of `x`, where `j` = `x / i`\n\nSince we are using union-find to track the parent representatives `P` of each disjoint set, we only need to track a single member `x` of each set for each factor `x`, `i`, `j` for case 1, 2, 3 correspondingly.  As sets are joined, their length `L` is accumulated and tracked by each parent reprentative.  Return the maxmium length of any parent reprensentative\'s set.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n    fun largestComponentSize(A: IntArray, N: Int = (1e5 + 1).toInt()): Int {\n        var P = IntArray(N) { it }              // \uD83D\uDE42 parent representative of disjoint sets\n        var L = IntArray(N) { 1 }               // \uD83E\uDD25 length of parent representative\'s set\n        fun find(x: Int): Int {\n            if (P[x] == x)\n                return x\n            P[x] = find(P[x])\n            return P[x]\n        }\n        fun union(a_: Int, b_: Int) {\n            var (a, b) = listOf(a_, b_)\n            a = find(a)\n            b = find(b)\n            if (a == b)\n                return\n            P[a] = b; L[b] += L[a]  // arbitrary choice\n        }\n        var m = mutableMapOf<Int, Int>()  // x,i,j factors of x -> x\n        for (x in A) {\n            if (m.contains(x)) union(m[x]!!, x) else m[x] = x      // case 1: x as a factor of itself\n            for (i in 2..Math.floor(Math.sqrt(x.toDouble())).toInt()) {\n                if (x % i != 0)\n                    continue\n                var j = x / i\n                if (m.contains(i)) union(m[i]!!, x) else m[i] = x  // case 2: i-th factor of x\n                if (m.contains(j)) union(m[j]!!, x) else m[j] = x  // case 3: j-th factor of x\n            }\n        }\n        return L.max()!!  // \uD83C\uDFAF maximum length of any parent representative\'s set\n    }\n}\n```\n\n*Javascript*\n```\nlet largestComponentSize = (A, N = 100001, m = {}) => {\n    let P = [...Array(N).keys()],              // \uD83D\uDE42 parent representative of disjoint sets\n        L = Array(N).fill(1);                  // \uD83E\uDD25 length of parent representative\'s set\n    let find = x => P[x] = x == P[x] ? P[x] : find(P[x]);\n    let union = (a, b) => {\n        a = find(a);\n        b = find(b);\n        if (a == b)\n            return;\n        P[b] = a;  // arbitrary choice\n        L[a] += L[b];\n    }\n    for (let x of A) {\n        m[x] ? union(m[x], x) : m[x] = x;      // case 1: x as a factor of itself\n        for (let i = 2; i * i <= x; ++i) {\n            if (x % i)\n                continue;\n            let j = Math.floor(x / i);\n            m[i] ? union(m[i], x) : m[i] = x;  // case 2: i-th factor of x\n            m[j] ? union(m[j], x) : m[j] = x;  // case 3: j-th factor of x\n        }\n    }\n    return Math.max(...L);                     // \uD83C\uDFAF maximum length of any parent representative\'s set\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def largestComponentSize(self, A: List[int], N = 100001) -> int:\n        m = {}\n        P = [i for i in range(N)]   # \uD83D\uDE42 parent representative of disjoint sets\n        L = [1] * N                 # \uD83E\uDD25 length of parent representative\'s set\n        def find(x):\n            P[x] = P[x] if x == P[x] else find(P[x])\n            return P[x]\n        def union(a, b):\n            a = find(a)\n            b = find(b)\n            if a == b:\n                return\n            P[b] = a  # arbitrary choice\n            L[a] += L[b]\n        for x in A:\n            m[x] = x if x not in m else m[x]; union(m[x], x)      # case 1: x as a factor of itself\n            for i in range(2, floor(sqrt(x)) + 1):\n                if x % i:\n                    continue\n                j = x // i\n                m[i] = x if i not in m else m[i]; union(m[i], x)  # case 2: i-th factor of x\n                m[j] = x if j not in m else m[j]; union(m[j], x)  # case 3: j-th factor of x\n        return max(L)  # \uD83C\uDFAF maximum length of any parent representative\'s set\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using VI = vector<int>;\n    using Map = unordered_map<int, int>;\n    using fun = function<int(int)>;\n    int largestComponentSize(VI& A, int N = 100001, Map m = {}) {\n        VI P(N); iota(P.begin(), P.end(), 0);               // \uD83D\uDE42 parent representative of disjoint sets\n        VI L(N, 1);                                         // \uD83E\uDD25 length of parent representative\'s set\n        fun find = [&](auto x) { return P[x] = x == P[x] ? P[x] : find(P[x]); };\n        auto _union = [&](auto a, auto b) {\n            a = find(a);\n            b = find(b);\n            if (a == b)\n                return;\n            P[b] = a;  // arbitrary choice\n            L[a] += L[b];\n        };\n        for (auto x: A) {\n            if (m[x]) _union(m[x], x); else m[x] = x;      // case 1: x as a factor of itself\n            for (auto i{ 2 }; i * i <= x; ++i) {\n                if (x % i)\n                    continue;\n                auto j = x / i;\n                if (m[i]) _union(m[i], x); else m[i] = x;  // case 2: i-th factor of x\n                if (m[j]) _union(m[j], x); else m[j] = x;  // case 3: j-th factor of x\n            }\n        }\n        return *max_element(L.begin(), L.end());           // \uD83C\uDFAF maximum length of any parent representative\'s set\n    }\n};\n```
[]