Java union find
```\n class UnionFind{\n        \n        int[] p;\n        int[] r ;\n        UnionFind(){\n            \n            p = new int[26];\n            r = new int
```\n class UnionFind{\n        \n        int[] p;\n        int[] r ;\n        UnionFind(){\n            \n            p = new int[26];\n            r = new int[26];\n            \n            for(int i=0 ; i<26 ; i++){\n                \n                p[i] = i;\n            }\n        }\n        \n        int find(int a){\n            \n            while(a!=p[a]){\n                \n                a = p[a];\n            }\n            \n            return a ;\n        }\n        \n        void union(int a, int b){\n            \n            int rootA = find(a);\n            int rootB = find(b);\n            \n            if(rootA==rootB) return ;\n            \n            if(rootA<rootB){\n                \n                p[rootB] = rootA ;\n            }\n            else{\n                \n                p[rootA] = rootB ;\n            }\n        }\n    }\n    \n    public String smallestEquivalentString(String s1, String s2, String baseStr) {\n        \n        \n        UnionFind uf = new UnionFind();\n        \n        StringBuilder sb  = new StringBuilder();\n        \n        for(int i=0 ; i<s1.length() ; i++){\n            \n            int f = s1.charAt(i)-\'a\';\n            int s = s2.charAt(i)-\'a\';\n            \n            uf.union(f,s);\n        }\n        \n        for(int i=0 ; i<baseStr.length() ; i++){\n            \n            int b  = uf.find(baseStr.charAt(i)-\'a\');\n            \n            sb.append((char)(b+\'a\'));\n        }\n        \n        return sb.toString();\n    }
['Union Find', 'Java']