C++ simple compact Union-Find  97% space and time
Time Complexity is O(N * sqrt(max(arr[i])).\nThe idea is that for every number we find and link all of its  factors to a unique parent number. Then simply count
Time Complexity is **O(N * sqrt(max(arr[i]))**.\nThe idea is that for every number we find and link all of its  factors to a unique parent number. Then simply count the numbers which has the given parent and output the maximum such frequency.\n```\nint parent[100001];\nint find (int x)\n{\n    if(parent[x]==-1)\n        return x;\n    else return parent[x]=find(parent[x]);\n}\nbool uni(int x,int y)\n{\n    int xp=find(x);\n    int yp=find(y);\n    if(xp!=yp)\n        parent[yp]=xp;\n    else return false;\n    return true;\n}\nint largestComponentSize(vector<int>& arr) \n{\n    unordered_map<int,int> memo;\n    memset(parent,-1,sizeof(parent));\n    int ret=0;\n    for(int x:arr)\n    {\n       int flag=0;\n        for(int i=2;i*i<=x;++i)\n            if(x%i==0)\n            {\n                uni(i,x);\n                uni(x,x/i);\n                flag=1;\n            }\n    }\n    for(int x:arr)\n        ret=max(ret,++memo[find(x)]);\n    return ret;\n}\n```
['Union Find', 'C']