[Python] Union Find [BEST SOLUTION]
\nclass Solution:\n    def friendRequests(self, n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]:\n        uf = {i:i for i in ran
```\nclass Solution:\n    def friendRequests(self, n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]:\n        uf = {i:i for i in range(n)}\n        ans = [None] * len(requests)\n        \n        def find(i):\n            if uf[i] != i:\n                uf[i] = find(uf[i])\n            return uf[i]\n        \n        def union(i, j):\n            uf[find(i)] = uf[find(j)]\n        \n        for i, (p1, p2) in enumerate(requests):\n            foundSet = set([find(p1), find(p2)])\n            ans[i] = not any(find(r1) in foundSet and find(r2) in foundSet \\\n                        for (r1, r2) in restrictions)\n            \n            if ans[i] == True:\n                union(p1, p2)\n    \n        return ans\n```
[]