Complexity?
Complexity\nSomeone can help calculate the complexity of my solution?\nI think it\'s O(#reqs.#restr.log(#reqs)) but really unsure.\n\n# Code\n\nclass Solution {
# Complexity\nSomeone can help calculate the complexity of my solution?\nI think it\'s O(#reqs.#restr.log(#reqs)) but really unsure.\n\n# Code\n```\nclass Solution {\n    // 13:51 -> 14:24\n\n    private int[] parents;\n\n    // [[0,1]]   -- [[0,2],[2,1]]\n    public boolean[] friendRequests(int n, int[][] restrictions, int[][] requests) {\n        parents = new int[n]; // 2 -1 -1\n        Arrays.fill(parents, -1);\n        int index = 0;\n        boolean[] res = new boolean[requests.length];\n        for (int[] request : requests) {\n            int root1 = parent(request[0]); // 2\n            int root2 = parent(request[1]); // 1\n\n            if (root1 == root2) {\n                res[index++] = true;\n            } else {\n                boolean canBeFriend = true;\n                for (int[] restr : restrictions) {\n                    if ((parent(restr[0]) == root1 && parent(restr[1]) == root2)\n                    || (parent(restr[0]) == root2 && parent(restr[1]) == root1)) { // 1 2\n                        canBeFriend = false;\n                        break;\n                    }\n                }\n\n                if (canBeFriend) {\n                    parents[root1] = root2;\n                }\n                res[index++] = canBeFriend;\n            }\n        }\n        return res;\n    }\n\n    private int parent(int person) {\n        int parent = parents[person];\n        if (parent == -1) {\n            return person;\n        } else {\n            return parents[person] = parent(parent);\n        }\n    }\n}\n```
['Java']