Brute force Java Solution use find and HashMap
Basic idea is use find the prime number factor as root and union connect the root with each other, and find the largest root that have maxium number of node.\n\
Basic idea is use find the prime number factor as root and union connect the root with each other, and find the largest root that have maxium number of node.\n```\nclass Solution {\n    static int[] root = new int[100001];\n    static boolean[] prime = new boolean[100001];\n    public int largestComponentSize(int[] nums) {\n        //union find\n        //if two have some factor bigger than one connect\n        //count the number of connect node\n        for(int i = 0;i < 100000;i++){\n            root[i] = i;\n            prime[i] = true;\n        }\n        Set<Integer> set = new HashSet<>();\n        for(int n:nums) set.add(n); \n        //filter the not prime number\n        for(int i = 2;i <= 100000;i++){\n            if(prime[i]){\n                for(int j = i*2;j <= 100000;j += i){\n                     prime[j] = false;\n                     if(set.contains(j)) root[find(j)] = find(i);\n                }\n            }\n        }\n        //count the root num that have most count;\n        Map<Integer,Integer> rootCount = new HashMap<>();\n        int largestSize = 1;\n        for(int i = 0;i < nums.length;i++){\n            int rootCur = find(nums[i]);\n            rootCount.put(rootCur,rootCount.getOrDefault(rootCur,0)+1);\n            largestSize = Math.max(rootCount.get(rootCur),largestSize);\n        }\n        return largestSize;\n    }\n    private int find(int a){\n        if(root[a] != a){\n            return find(root[a]);\n        }\n        return root[a];\n    }\n}\n```
['Java']