Java, Union-Find
\nclass Solution {\n    public boolean[] friendRequests(int n, int[][] restrictions, int[][] requests) {\n        \n        Map<Integer, UF> ufs = new HashMap<>
```\nclass Solution {\n    public boolean[] friendRequests(int n, int[][] restrictions, int[][] requests) {\n        \n        Map<Integer, UF> ufs = new HashMap<>();\n        Map<Integer, Set<Integer>> groupMembers = new HashMap<>();\n        Map<Integer, Set<Integer>> groupToExcludedMembers = new HashMap<>();\n        \n        int groupId = 1;\n        \n        for (int i = 0; i < n; i++) {\n            UF uf = new UF();\n            uf.group = groupId;\n            \n            ufs.put(i, uf);\n            groupMembers.put(groupId, new HashSet<>());\n            groupMembers.get(groupId).add(i);\n            \n            groupToExcludedMembers.put(groupId, new HashSet<>());\n            \n            groupId++;\n        }\n        \n        for (int[] restriction : restrictions) {\n            int one = restriction[0];\n            int other = restriction[1];\n            \n            groupToExcludedMembers.get(one + 1).add(other);\n            groupToExcludedMembers.get(other + 1).add(one);\n        }\n        \n        int length = requests.length;\n        \n        boolean[] result = new boolean[length];\n        \n        int index = 0;\n        \n        for (int[] request : requests) {\n            \n            int alice = request[0];\n            int bob = request[1];\n            \n            UF uf1 = ufs.get(alice).get();\n            UF uf2 = ufs.get(bob).get();\n            \n            int group1 = uf1.group;\n            int group2 = uf2.group;\n            \n            if (group1 == group2) {\n                result[index] = true;\n            } else {\n                Set<Integer> members1 = groupMembers.get(group1);\n                Set<Integer> members2 = groupMembers.get(group2);\n                \n                Set<Integer> excludedMembers1 = groupToExcludedMembers.get(group1);\n                Set<Integer> excludedMembers2 = groupToExcludedMembers.get(group2);\n                \n                if (Collections.disjoint(members1, excludedMembers2) && Collections.disjoint(members2, excludedMembers1)) {\n                    if (group1 < group2) {\n                        members1.addAll(members2);\n                        excludedMembers1.addAll(excludedMembers2);\n                    \n                        groupMembers.remove(group2);\n                        groupToExcludedMembers.remove(group2);\n                        uf2.parent = uf1;\n                    } else {\n                        members2.addAll(members1);\n                        excludedMembers2.addAll(excludedMembers1);\n                    \n                        groupMembers.remove(group1);\n                        groupToExcludedMembers.remove(group1);\n                        uf1.parent = uf2;\n                    }\n                    \n                    result[index] = true;\n                } else {\n                    result[index] = false;\n                }\n            }\n            \n            index++;\n        }\n        \n        return result;\n    }\n    \n    static class UF {\n        Integer group;\n        UF parent;\n        \n        UF get() {\n            if (parent == null) {\n                return this;\n            } else {\n                if (parent.parent != null) {\n                    parent = parent.parent;\n                }\n                return parent.get();\n            }\n        }\n        \n    }\n}\n```
['Union Find', 'Java']