Go/ Python  O(max(n,m)) time | O(max(n,m)) space
Complexity\n- Time complexity: O(max(n,m))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(max(n,m))\n Add your space complexity here, e.g.
# Complexity\n- Time complexity: $$O(max(n,m))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(max(n,m))$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```golang []\nfunc smallestEquivalentString(s1 string, s2 string, baseStr string) string {\n    graph := make(map[rune]map[rune]bool)\n    for i,_ := range(s1){\n        p := rune(s1[i])\n        q := rune(s2[i])\n        if _,ok := graph[p]; !ok{\n            graph[p] = make(map[rune]bool)\n        }\n        if _,ok := graph[q]; !ok{\n            graph[q] = make(map[rune]bool)\n        }\n        graph[p][q] = true\n        graph[q][p] = true\n    }\n    \n    answer := []rune{}\n    for _,char := range(baseStr){\n        visited := make(map[rune]bool)\n        answer = append(answer,dfs(char, graph, visited))\n    }\n    return string(answer)\n}\n\nfunc dfs(node rune, graph map[rune]map[rune]bool, visited map[rune]bool) rune{\n    if _,ok := visited[node]; ok{\n        return node\n    }\n        \n    visited[node] = true\n    letter := node\n    \n    for n,_ := range(graph[node]){\n        letter = min(letter, dfs(n, graph, visited))\n    }\n    return letter\n}\n\nfunc min(a,b rune) rune{\n    if a < b{\n        return a\n    }\n    return b\n}\n```\n```python []\nclass Solution:\n    def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str:\n        graph = defaultdict(set)\n        for p, q in zip(s1, s2):\n            graph[p].add(q)\n            graph[q].add(p)\n        \n        answer = []\n        for char in baseStr:\n            visited = set()\n            answer.append(dfs(char, graph, visited))\n        return "".join(answer)\n\ndef dfs(node, graph, visited):\n    if node in visited:\n        return node\n        \n    visited.add(node)\n    letter = node\n    \n    for n in graph[node]:\n        letter = min(letter, dfs(n, graph, visited))\n    return letter\n```
['Hash Table', 'String', 'Depth-First Search', 'Go', 'Python3']