C++ | Easy to understand
```\nclass Solution {\n    int par[100001],rank_[100001],ans;\n    int find(int x)\n    {\n        return (par[x]==x?x:par[x]=find(par[x]));\n    }\n    void un
```\nclass Solution {\n    int par[100001],rank_[100001],ans;\n    int find(int x)\n    {\n        return (par[x]==x?x:par[x]=find(par[x]));\n    }\n    void union_(int a,int b)\n    {\n        a=find(a); b=find(b);\n        if(a==b)return;\n        if(rank_[a]>=rank_[b])\n        {\n            par[b]=a; rank_[a] += rank_[b];\n        }\n        else\n        {\n            rank_[b] += rank_[a]; par[a]=b;\n        }\n        ans = max(ans,max(rank_[a],rank_[b]));\n    }\npublic:\n    int largestComponentSize(vector<int>& nums) {\n        ans = 1;\n        for(int i=1;i<=100000;i++)\n        {\n            par[i]=i; rank_[i]=0;\n        }\n        for(int i=0;i<nums.size();i++)\n            rank_[nums[i]]=1;\n        \n        int n = nums.size();\n        for(int i=0;i<n;i++)\n        {\n            for(int j=2;j*j<=nums[i];j++)\n            {\n                if(nums[i]%j == 0)\n                {\n                    union_(j,nums[i]);\n                    union_(j,nums[i]/j);\n                }\n            }\n        }\n        return ans;\n        \n    }\n};
[]