Java, Union Find
\nclass Solution {\n    public boolean[] friendRequests(int n, int[][] re, int[][] requests) {\n        UnionFind uf = new UnionFind();\n        boolean[] res =
```\nclass Solution {\n    public boolean[] friendRequests(int n, int[][] re, int[][] requests) {\n        UnionFind uf = new UnionFind();\n        boolean[] res = new boolean[requests.length];\n        Arrays.fill(res,true);\n        for(int i = 0; i < requests.length; i++){\n            int[] r =requests[i];\n            int a = r[0], b = r[1];\n            int a1 = uf.find(a), b1 = uf.find(b);\n            for(int[] t: re){\n                int t1 = uf.find(t[0]), t2 = uf.find(t[1]);\n                if(t1 == a1 && b1 == t2 || a1 == t2 && b1 == t1){\n                    res[i] = false;\n                    break;\n                }\n            }\n            if(res[i]) uf.union(a,b);\n        }\n        return res;\n    }\n    \n}\n\nclass UnionFind{\n    Map<Integer, Integer> map = new HashMap<>();\n    int find(int n){\n        map.putIfAbsent(n,n);\n        while(n != map.get(n)){\n            map.put(n, map.get(map.get(n)));\n            n = map.get(n);\n        }\n        return n;\n    }\n    void union(int a, int b){\n        map.put(find(a), find(b));\n    }\n}\n```
[]