UNION FIND + Prime Factorization C++ Solution
\nclass Solution {\n    vector<int> parent;\npublic:\n    int find(int x){\n        if(parent[x]==-1) return x;\n        return parent[x]=find(parent[x]);\n    
```\nclass Solution {\n    vector<int> parent;\npublic:\n    int find(int x){\n        if(parent[x]==-1) return x;\n        return parent[x]=find(parent[x]);\n    }\n    void unio(int x,int y){\n        int xd=find(x);\n        int yd=find(y);\n        if(xd!=yd){\n            parent[xd]=yd;\n        }\n    }\n    int largestComponentSize(vector<int>& A) {\n        parent.resize(1000000+1,-1);\n        for(auto a:A){\n            int n=a;\n            int count=0;\n            while(n%2==0){\n                n>>=1;\n                count++;\n            }\n            if(count){\n                unio(a,2);\n            }\n            for(int i=3;i<=sqrt(n);i++){\n                int c=0;\n                while(n%i==0){\n                    n=n/i;\n                    c++;\n                }\n                if(c){\n                    unio(a,i);\n                }\n            }\n            if(n>2){\n                unio(a,n);\n            }\n        }\n        unordered_map<int,int> mp;\n        for(auto a:A){\n            mp[find(a)]++;\n        }\n        int ans=1;\n        for(auto m:mp){\n            ans=max(ans,m.second);\n        }\n        return ans;\n    }\n};\n```
['Union Find', 'C', 'C++']