Using DFS without Union find
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:m*(E+V):\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 Solution {\npublic:\n    char DfsFindMinChar(unordered_map<char,vector<char>> &adj, char curr_char,vector<int>&vis){\n        vis[curr_char-\'a\']=1;\n        char miniChar = curr_char;\n\n        for(auto &v: adj[curr_char]){\n            if(!vis[v-\'a\']){\n                miniChar=min(miniChar,DfsFindMinChar(adj,v,vis));\n            }\n        }\n        return miniChar;\n\n    }\n    string smallestEquivalentString(string s1, string s2, string baseStr) {\n        int n = s1.size();\n        int m=baseStr.size();\n        unordered_map<char,vector<char>> adj;\n\n        for(int i=0; i<n; i++){\n            char u = s1[i];\n            char v = s2[i];\n\n            adj[u].push_back(v);\n            adj[v].push_back(u);\n        }\n        string result;\n        \n        for(int i=0; i<m; i++){\n            char ch = baseStr[i];\n            vector<int> vis(26,0);\n            char minChar=DfsFindMinChar(adj,ch,vis);\n\n            result.push_back(minChar);\n        }\n        return result;\n\n    }\n};\n```
['C++']