Solution in O(n) using union find
Intuition\n Describe your first thoughts on how to solve this problem. \nSince we have to map one character to another, but one or more character can point to s
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSince we have to map one character to another, but one or more character can point to same character. So there comes union find to make parent of each character.\nAfter making parent of each character now the answer string is parent of each character in the baseStr.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIterate over s1 and s2 and make union of character of s1 and s2.\nsince we want lexicographically small string as answer so instead of giving rank numbers, character have rank acording to dictionary order i.e. a = 0 , b= 1, ... z = 25.\nSo the union or join function make parent to the character which has less rank.\n\nNow iterate over BaseStr and change each character to its parent character.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$o(n)$$ \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$o(1)$$  using array of size 26 is constant space\n# Code\n```\nclass Solution {\npublic:\n    int par[26];\n    void makedsu(){\n        for(int i=0;i<26;i++){\n            par[i] = i;\n        }\n    }\n    int getpar(int a){\n        if(par[a] == a) return a;\n        return par[a] = getpar(par[a]);\n    }\n    void dsjoint(int a,int b){\n        a = getpar(a);\n        b = getpar(b);\n        if(a < b) par[b] = a;\n        else par[a] = b; \n    }\n    string smallestEquivalentString(string s1, string s2, string baseStr) {\n        makedsu();\n        for(int i=0;i<s1.size();i++){\n            int a= (s1[i] - \'a\');\n            int b = (s2[i]-\'a\');\n            dsjoint(a,b);\n        }\n        string s = "";\n        for(int i=0;i<baseStr.size();i++){\n            int a = getpar((int)(baseStr[i]-\'a\'));\n            s += (a+\'a\');\n        }\n        return s;\n    }\n};\n```
['Union Find', 'C++']