python3 simple union find
\n\n# Code\n\nclass Solution:\n    def friendRequests(self, n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]:\n        res = []\n
\n\n# Code\n```\nclass Solution:\n    def friendRequests(self, n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]:\n        res = []\n        self.parent = list(range(n))\n        for a,b in requests:\n            temp = self.parent.copy()\n            self.union(a,b)\n            flag = True\n            for x,y in restrictions:\n                if self.find(x)==self.find(y):\n                    flag = False\n                    break\n            if flag:\n                res.append(True)\n            else:\n                res.append(False)\n                self.parent = temp\n        \n        return res\n\n    def find(self, a):\n        acopy = a\n        while a != self.parent[a]:\n            a = self.parent[a]\n        while acopy != a:\n            self.parent[acopy], acopy = a, self.parent[acopy]\n        return a\n        \n    def union(self, a, b):\n        self.parent[self.find(b)] = self.find(a)\n\n```
['Python3']