Implemented Optimized Version Of UnionFind data structure
Use The optimized version of UnionFind data structure