DFS
\nclass Solution {\npublic:\n    \n    char dfs(unordered_map<char,string> &mp, vector<bool> &v, char c)\n    {\n        \n        v[c-\'a\'] = true;\n        c
```\nclass Solution {\npublic:\n    \n    char dfs(unordered_map<char,string> &mp, vector<bool> &v, char c)\n    {\n        \n        v[c-\'a\'] = true;\n        char res = c;\n        for(int i=0;i<mp[c].length();i++)\n        {\n            \n            if(!v[mp[c][i]-\'a\'])\n            {\n                res = min(dfs(mp,v,mp[c][i]),res);\n                \n            }\n        }\n        \n        return res;\n    }\n    \n    \n    string smallestEquivalentString(string s1, string s2, string bs) {\n        int n = s1.length();\n        \n        unordered_map<char,string> mp;\n        for(int i=0;i<n;i++)\n        {\n            char u = s1[i];\n            char v = s2[i];\n            \n            mp[u].push_back(v);\n            mp[v].push_back(u);\n        }\n        \n        string res = "";\n        for(int i = 0;i<bs.length();i++)\n        {\n            vector<bool> vis(26,0);\n            char c = dfs(mp,vis,bs[i]);\n            res.push_back(c);\n        }\n        \n        return res;\n    }\n};\n```
['C']