python union find
```\nclass UF:\n    def init(self, n):\n        self.ps = list(range(n))\n\n    def find(self, x):\n        if self.ps[x] != x:\n            self.ps[x] = self.f
```\nclass UF:\n    def __init__(self, n):\n        self.ps = list(range(n))\n\n    def find(self, x):\n        if self.ps[x] != x:\n            self.ps[x] = self.find(self.ps[x])\n        return self.ps[x]\n\n    def union(self, x, y):\n        px, py = self.find(x), self.find(y)\n        if px == py:\n            return\n        if px < py:\n            self.ps[py] = px\n        else:\n            self.ps[px] = py\n\n\nclass Solution:\n    def smallestEquivalentString(self, A: str, B: str, S: str) -> str:\n\n        uf = UF(26)\n        for a, b in zip(A, B):\n            if a != b:\n                uf.union(ord(a) - 97, ord(b) - 97)\n\n        return \'\'.join((chr(uf.find(ord(c) - 97) + 97) for c in list(S)))
[]