✔ Python3 Solution | Union Find
Complexity\n- Time complexity: O(n + m)\n- Space complexity: O(1)\n\n# Code\n\nclass Solution:\n    def smallestEquivalentString(self, s1: str, s2: str, baseStr
# Complexity\n- Time complexity: $$O(n + m)$$\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution:\n    def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str:\n        D = {i: i for i in ascii_lowercase}\n        def parent(x):\n            if D[x] == x: return x\n            x = parent(D[x])\n            return x\n        def union(x, y):\n            u, v = parent(x), parent(y)\n            D[u] = D[v] = min(u, v)\n        for a, b in zip(s1, s2):\n            union(a, b)\n        return \'\'.join([parent(i) for i in baseStr])\n```
['String', 'Union Find', 'Python3']