Python | Union Find | Easy and Simple Solution
\n# Code\n\nfrom collections import defaultdict\nclass Solution:\n    def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str:\n        parent
\n# Code\n```\nfrom collections import defaultdict\nclass Solution:\n    def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str:\n        parent = defaultdict(str)\n        for c in \'abcdefghijklmnopqrstuvwxyz\':\n            parent[c] = c \n        def find(v):\n            if parent[v] != v:\n                parent[v] = find(parent[v])\n            return parent[v]\n        def union(v,w):\n            pv, pw = find(v), find(w)\n            if pv < pw:\n                parent[pw] = pv\n            else:\n                parent[pv] = pw \n        for v, w in zip(s1, s2):\n            union(v, w)\n        res = []\n        for c in baseStr:\n            res.append(find(c))\n        return "".join(res)\n```
['Python3']