Simple Intuitive solution || C++ Clean Code
Code\n\nclass Solution {\npublic:\n    void refineMap(map<char, set<char>> &mp, int times) {\n        while(times--) {\n            for(auto [k, v]: mp)\n      
# Code\n```\nclass Solution {\npublic:\n    void refineMap(map<char, set<char>> &mp, int times) {\n        while(times--) {\n            for(auto [k, v]: mp)\n                for(char i: v) mp[k].insert(*mp[i].begin());\n        }\n    }\n\n    string smallestEquivalentString(string s1, string s2, string baseStr) {\n        map<char, set<char>> mp;\n        int n = s1.size(); string res = "";\n        \n        for(int i = 0; i < n; i++)\n            mp[s1[i]].insert(s2[i]);\n        \n        for(int i = 0; i < n; i++) {\n            if(mp.find(s1[i]) != mp.end())\n                for(char x: mp[s1[i]])\n                    mp[s2[i]].insert(x);\n            mp[s2[i]].insert(s1[i]);\n        } refineMap(mp, 2);\n\n        for(char i: baseStr) {\n            if(mp.find(i) != mp.end()) res += *mp[i].begin();\n            else res += i;\n        } return res;\n    }\n};\n```
['C++']