Easy java implementation
\nclass Solution {\n    public int find(int x,int[] parent)\n    {\n        if(parent[x]==-1)\n            return x;\n        else\n            parent[x]=find(p
```\nclass Solution {\n    public int find(int x,int[] parent)\n    {\n        if(parent[x]==-1)\n            return x;\n        else\n            parent[x]=find(parent[x],parent);\n        return parent[x];\n    }\n    public void union(int x,int y,int[] parent)\n    {\n        int xp=find(x,parent);\n        int yp=find(y,parent);\n        if(xp!=yp)\n        {\n            parent[yp]=xp;\n        }\n        return;\n    }\n    public int largestComponentSize(int[] nums) {\n        int[] parent=new int[100001];\n        Arrays.fill(parent,-1);\n        int i;\n        for(i=0;i<nums.length;i++)\n        {\n            for(int k=2;k<=Math.sqrt(nums[i]);k++)\n            {\n                if(nums[i]%k==0)\n                {\n                    union(nums[i],k,parent);\n                    union(nums[i],nums[i]/k,parent);\n                }\n            }\n        }\n        int count=0;\n        HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();\n        for(i=0;i<nums.length;i++)\n        {\n            int p=find(nums[i],parent);\n            count=Math.max(count,map.getOrDefault(p,0)+1);\n            map.put(p,map.getOrDefault(p,0)+1);\n        }\n        return count;\n    }\n```
['Union Find', 'Java']