Easy to follow Java Code, 12 ms time (beats 100%)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe runtime of the code is O(n * m). where n is the number of restrictions (restrictions.length) and m is the number of queries (requests.length).\n\nThe first loop in the DisjoinSet class takes O(n) time to initialize the parent and rank arrays. The second loop takes O(n) time to add each restriction to the appropriate set. The notRestricted() method takes O(1) time to check if two roots are restricted from being in the same set.\n\nThe union() method takes O(1) time to find the roots of the two nodes being unioned. If the two roots are not restricted from being in the same set, then the union() method takes O(1) time to union the two sets. If the two roots are restricted from being in the same set, then the union() method takes O(n) time to update the restrictions of the two sets.\n\nThe friendRequests() method takes O(m) time to iterate through the queries and call the union() method for each query.\n\nTherefore, the overall runtime of the code is O(n * m).\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n//Idea and code from \n// https://leetcode.com/problems/process-restricted-friend-requests/solutions/3814592/union-find-disjoint-sets-solution-faster-than-90-java/\n\nclass DisjoinSet {\n    private final int [] parent;\n    private final int [] rank;\n    private final List<Set<Integer>> restrictions;\n\n    DisjoinSet(int size, int[][] restrictions){\n        this.parent = new int [size];\n        this.rank = new int [size];     \n        this.restrictions = new ArrayList<>(size);\n\n        for(int i =0; i <size; i++) {\n            this.parent[i] = i;\n            this.rank[i] = 1;\n            this.restrictions.add(new HashSet<>());\n        }\n\n        for (int [] restriction: restrictions){\n            this.restrictions.get(restriction[0]).add(restriction[1]);\n            this.restrictions.get(restriction[1]).add(restriction[0]);\n        }\n    }\n\n    private int find(int node){\n        int root=node;\n        while(parent[root]!=root){\n            root=parent[root];\n        }\n\n        while (parent[node]!=root){\n            int next = parent[node];\n            parent[node]=root;\n            node = next;\n        }\n        return root;\n    }\n\n    public boolean union (int n1, int n2){\n        int p1 = find(n1);\n        int p2 = find(n2);\n\n        if (p1==p2){\n            return true;\n        }\n            \n        if (notRestricted(p1,p2)){\n            if (rank[p1]>rank[p2]){\n                rank[p1]+=rank[p2];\n                parent[p2]=p1;\n                // Combine the restrictions list\n                //Add all parent Nodes from other list \n                for (int node: restrictions.get(p2)){\n                    restrictions.get(p1).add(find(node) );\n                }\n            } else{\n                rank[p2]+=rank[p1];\n                parent[p1]= p2;\n                // Combine the restrictions list\n                //Add all parent Nodes from other list \n                for (int node: restrictions.get(p1)){\n                    restrictions.get(p2).add(find(node) );\n                }\n            }\n            return true;\n        }\n        return false;\n    }\n    \n        private boolean notRestricted(int root1, int root2) {\n            if (restrictions.get(root1).contains(root2))\n                return false;\n            if (restrictions.get(root2).contains(root1))\n                return false;\n        return true;\n    }\n}\n\nclass Solution {\n    public boolean[] friendRequests(int n, int[][] restrictions, int[][] requests) {\n        if (restrictions.length==0){\n            boolean [] queries = new boolean [requests.length];\n            Arrays.fill(queries,true);\n            return queries;\n        }\n         DisjoinSet set = new DisjoinSet(n,restrictions);\n         boolean [] queries = new boolean [requests.length];\n         for (int i =0; i<requests.length ;i++){\n            queries[i] = set.union(requests[i][0],requests[i][1] );\n         }\n        return queries;\n    }\n}\n```
['Java']