Rust UnionFind solution
rust\nuse std::collections::HashMap;\n\nstruct UnionFind {\n    parent: Vec<usize>,\n}\n\nimpl UnionFind {\n    fn new(n: usize) -> Self {\n        Self {\n    
```rust\nuse std::collections::HashMap;\n\nstruct UnionFind {\n    parent: Vec<usize>,\n}\n\nimpl UnionFind {\n    fn new(n: usize) -> Self {\n        Self {\n            parent: (0..n).collect(),\n        }\n    }\n    fn union(&mut self, x: usize, y: usize) {\n        let x = self.find(x);\n        let y = self.find(y);\n        self.parent[y] = x\n    }\n    fn find(&mut self, x: usize) -> usize {\n        if x != self.parent[x] {\n            self.parent[x] = self.find(self.parent[x]);\n        }\n        self.parent[x]\n    }\n}\n\nimpl Solution {\n    pub fn largest_component_size(nums: Vec<i32>) -> i32 {\n        let mut sieve = (0..100_001).collect::<Vec<_>>();\n        for i in (2..).take_while(|&i| i * i < 100_001) {\n            if sieve[i] == i as i32 {\n                for j in (i..100_001).step_by(i) {\n                    sieve[j] = sieve[j].min(i as i32);\n                }\n            }\n        }\n        let mut hm = HashMap::new();\n        for (i, &num) in nums.iter().enumerate() {\n            let mut n = num;\n            while n > 1 {\n                let p = sieve[n as usize];\n                hm.entry(p).or_insert_with(Vec::new).push(i);\n                n /= p as i32;\n            }\n        }\n        let mut uf = UnionFind::new(nums.len());\n        for v in hm.values_mut() {\n            v.dedup();\n            v.windows(2).for_each(|w| uf.union(w[0], w[1]));\n        }\n        let mut counts = vec![0; nums.len()];\n        for i in 0..nums.len() {\n            counts[uf.find(i)] += 1;\n        }\n        *counts.iter().max().unwrap() as i32\n    }\n}\n```
['Union Find', 'Rust']