C++ || UNION FIND
Code\n\nclass Solution {\npublic:\nint find(int a,vector<int> &p){\n    if(a == p[a])return a;\n    return p[a] = find(p[a],p);\n}\nvoid unon(int a,int b,vector
# Code\n```\nclass Solution {\npublic:\nint find(int a,vector<int> &p){\n    if(a == p[a])return a;\n    return p[a] = find(p[a],p);\n}\nvoid unon(int a,int b,vector<int> &s,vector<int> &p){\n    int x = find(a,p),y = find(b,p);\n    if(x != y){\n        if(s[y]<s[x])swap(x,y);\n        p[x] = y;\n        s[y] += s[x];\n    }\n}\n    int largestComponentSize(vector<int>& nums) {\n        int n = 1e5+1,i;\n        vector<int> s(n),p(n);\n        for(i = 0; i < n; i++){\n            s[i] = 1, p[i] = i;\n        }\n        for(auto &j: nums){\n            for(i = 2; i <= sqrt(j); i++){\n                if(j%i==0){\n                    unon(i,j,s,p);\n                    unon(j/i,j,s,p);\n                }\n            }\n        }\n        n = 0;\n        unordered_map<int,int> mp;\n        for(auto &i: nums){\n            mp[find(i,p)]++;\n            n = max(n,mp[find(i,p)]);\n        }\n        return n;\n    }\n};\n```
['Array', 'Union Find', 'Number Theory', 'C++']