shortest code in java using union find
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)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    int[] parent;\n    public boolean[] friendRequests(int n, int[][] restrictions, int[][] requests) {\n        parent = new int[n];\n        for (int i = 0; i < n; i++) {\n            parent[i] = i;\n        }\n        return processRequests(requests, restrictions);\n    }\n    private boolean[] processRequests(int[][] requests, int[][] restrictions) {\n        boolean[] res = new boolean[requests.length];\n        for (int i = 0; i < requests.length; i++) {\n            int a = find(requests[i][0]);\n            int b = find(requests[i][1]);\n            res[i] = checkRestrictions(a, b, restrictions);\n        }\n        return res;\n    }\n    private boolean checkRestrictions(int a, int b, int[][] restrictions) {\n        for (int i = 0; i < restrictions.length; i++) {\n            boolean isClear = isRestrictionClear(a, b, restrictions[i]);\n            if (!isClear) return false;\n        }\n        union(a, b);\n        return true;\n    }\n    private boolean isRestrictionClear(int a, int b, int[] restriction) {\n        int x = find(restriction[0]);\n        int y = find(restriction[1]);\n        if (a == x && b == y) return false;\n        if (a == y && b == x) return false;\n        return true;\n    }\n    private void union(int a, int b) {\n        int rootA = find(a);\n        int rootB = find(b);\n        parent[rootA] = rootB;\n    }\n    private int find(int a) {\n        if (parent[a] != a) {\n            parent[a] = find(parent[a]);\n        }\n        return parent[a];\n    }  \n}\n```
['Java']