✅✅UNION FIND C++ SOLTUION || SIEVE ALGORITHM✅
\nclass Solution {\npublic:\n    vector<int> dsu,si;\n    int find(int i)\n    {\n        if(i==dsu[i])return i;\n        return dsu[i] = find(dsu[i]);\n    }\n
```\nclass Solution {\npublic:\n    vector<int> dsu,si;\n    int find(int i)\n    {\n        if(i==dsu[i])return i;\n        return dsu[i] = find(dsu[i]);\n    }\n    void f(int u ,int v)\n    {\n        int uu = find(u);\n        int vv = find(v);\n        if(uu==vv)return ;\n        if(si[uu]<si[vv])\n        {\n            dsu[uu] = vv;\n            si[vv]+=si[uu];\n        }\n        else \n        {\n            dsu[vv] = uu;\n            si[uu]+=si[vv];\n        }\n    }\n    int largestComponentSize(vector<int>& nums) {\n      int n = nums.size(),x=0;\n        dsu.resize(1e6);\n        si.resize(1e6,1);\n        for(int i=0;i<1e6;i++)\n        {\n            dsu[i] = i;\n        }\n        unordered_set<int>s;\n        for(auto it:nums)\n        {\n          s.insert(it);\n            x = max(x,it);\n        }\n        for(int i=2;i<=x;i++)\n        {\n            int last =-1;\n            for(int j=i;j<=x;j+=i)\n            {\n                if(s.find(j)!=s.end())\n                {\n                    if(last==-1)last = j;\n                else\n                {\n                    f(last,j);\n                    last  = j;\n                }\n                }\n               \n            }\n        }\n        int res=0;\n        for(auto it:si)\n        {\n          res = max(res,it);\n        }\n        return res;\n      \n    }\n};\n```
['Union Find', 'C', 'C++']