java
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass DisjointSet{\n    int[] parent, size;\n    public DisjointSet(int n) {\n        parent = new int[n+1];\n        size = new int[n+1]; \n        for(int i = 0;i<=n;i++) {\n            parent[i] = i; \n            size[i] = 1; \n        }\n    }\n    int findPar(int node){\n        if(node==parent[node]) return node;\n        return parent[node] =findPar(parent[node]);\n    }\n    void unionBySize(int u, int v) {\n        int up = findPar(u); \n        int uv = findPar(v); \n        if(up == uv) return; \n        if(up < uv) {\n            parent[uv] = up; \n        }\n        else {\n            parent[up] = uv;\n        }\n    }\n}\nclass Solution {\n    public String smallestEquivalentString(String s1, String s2, String baseStr) {\n        int n = s1.length();\n        DisjointSet ds = new DisjointSet(26);\n        for(int i=0;i<n;i++){\n            ds.unionBySize(s1.charAt(i)-\'a\',s2.charAt(i)-\'a\');\n        }\n        StringBuilder res = new StringBuilder();\n        for(int i=0;i<baseStr.length();i++){\n            res.append((char)(ds.findPar(baseStr.charAt(i)-\'a\')+\'a\'));\n        }\n        return res.toString();\n    }\n}\n```
['Java']