[Python3] union-find
Please check out this commit for solutions of weekly 267.\n\nclass UnionFind:\n\n\tdef __init__(self, n: int):\n\t\tself.parent = list(range(n))\n\t\tself.rank 
Please check out this [commit](https://github.com/gaosanyong/leetcode/commit/8d693371fa97ea3b0717d02448c77201b15e5d12) for solutions of weekly 267.\n```\nclass UnionFind:\n\n\tdef __init__(self, n: int):\n\t\tself.parent = list(range(n))\n\t\tself.rank = [1] * n\n\n\tdef find(self, p: int, halving: bool=True) -> int:\n\t\tif p != self.parent[p]:\n\t\t\tself.parent[p] = self.find(self.parent[p]) \n\t\treturn self.parent[p]\n\n\tdef union(self, p: int, q: int) -> bool:\n\t\tprt, qrt = self.find(p), self.find(q)\n\t\tif prt == qrt: return False \n\t\tif self.rank[prt] > self.rank[qrt]: prt, qrt = qrt, prt \n\t\tself.parent[prt] = qrt\n\t\tself.rank[qrt] += self.rank[prt]\n\t\treturn True\n\n\nclass Solution:\n    def friendRequests(self, n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]:\n        ans = []\n        uf = UnionFind(n)\n        for u, v in requests: \n            uu = uf.find(u)\n            vv = uf.find(v)\n            for x, y in restrictions: \n                xx = uf.find(x)\n                yy = uf.find(y)\n                if uu == xx and vv == yy or uu == yy and vv == xx: \n                    ans.append(False)\n                    break \n            else: \n                ans.append(True)\n                uf.union(u, v)\n        return ans \n```
['Python3']