Time Complexity -> O(N*N) using DSU
Intuition\n Describe your first thoughts on how to solve this problem. \n\n1) Consider each person as a node of a graph and there is an unidrected edge between 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n1) Consider each person as a node of a graph and there is an unidrected edge between two node if both are friends.\n\n2) For each request we can simply add an edge between two nodes. After connecting an edge check is there any restriction that is connected.\n\n3) If there is restriction that is connected it means that particular request is unsuccessful and if there is no restriction that is connected it means that particular request is successful.\n\n# Code\n```\nclass Solution {\npublic:\n\nclass DSU {\n\n    private:\n   \n        int parent[1001];\n        int rank[1001];\n   \n    public:\n        \n        DSU(int n) {\n            \n            for(int i = 0; i < n; i++) {\n                parent[i] = i;\n                rank[i] = 0;\n            }\n\n        }\n\n        int ultparent(int node) {\n            if(parent[node] == node) return node;\n            return parent[node] = ultparent(parent[node]);\n        }\n\n        bool connected(int node1, int node2) {\n            \n            int parent1 = ultparent(node1);\n            int parent2 = ultparent(node2);\n\n            if(parent1 == parent2) return true;\n            else return false;\n\n        }\n\n        void unionbyrank(int node1, int node2) {\n            \n            int parent1 = ultparent(node1);\n            int parent2 = ultparent(node2);\n\n            if(parent1 == parent2) return;\n            else {\n                if(rank[parent1] < rank[parent2]) {\n                    parent[parent1] = parent2;\n                } else if(rank[parent1] > rank[parent2]) {\n                    parent[parent2] = parent1;\n                } else {\n                    parent[parent1] = parent2;\n                    rank[parent2]++;\n                }\n            }\n\n        }\n\n    };\n  \n \n\n\n\n\n    vector<bool> friendRequests(int n, vector<vector<int>>& res, vector<vector<int>>& req) {\n        \n        DSU graph(n);\n        vector<bool>ans(req.size());\n\n        for(int i = 0; i < req.size(); i++) {\n            \n            int u = req[i][0];\n            int v = req[i][1];\n\n            DSU dummyGraph(n);\n            dummyGraph = graph;\n\n            dummyGraph.unionbyrank(u, v);\n\n            bool successful = true;\n\n\n            for(int j = 0; j < res.size(); j++) {\n                \n                int a = res[j][0];\n                int b = res[j][1];\n\n                if(dummyGraph.connected(a, b)) {\n                    successful = false;\n                }\n\n            }\n\n            if(successful) {\n                ans[i] = true;\n                graph.unionbyrank(u, v);\n            } else {\n                ans[i] = false;\n            }\n\n        }\n\n        return ans;\n\n    } \n};\n```
['C++']