[Python3] Simple Union Find - easy to understand
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:\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 UnionFind:\n\n    def __init__(self):\n        self.root = list(range(26))\n    \n    def find(self, x: int) -> int:\n        if x == self.root[x]:\n            return x\n        \n        self.root[x] = self.find(self.root[x])\n        return self.root[x]\n\n    def union(self, x: int, y: int) -> None:\n        root_x, root_y = self.find(x), self.find(y)\n        if root_x == root_y:\n            return\n        \n        if root_x < root_y:\n            self.root[root_y] = root_x\n        else:\n            self.root[root_x] = root_y\n\nclass Solution:\n    def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str:\n        uf = UnionFind()\n        for i in range(len(s1)):\n            i1, i2 = ord(s1[i]) - ord(\'a\'), ord(s2[i]) - ord(\'a\')\n            uf.union(i1, i2)\n        res = []\n        for c in baseStr:\n            i = ord(c) - ord(\'a\')\n            new_char = chr(uf.find(i) + ord(\'a\'))\n            res.append(new_char)\n        \n        return \'\'.join(res)\n```
['String', 'Union Find', 'Python3']