Simple DFS code
Intuition\n Describe your first thoughts on how to solve this problem. \nwe need to take care that the restriction edge\'s node should not belong from the same 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe need to take care that the restriction edge\'s node should not belong from the same node \n# Approach\n<!-- Describe your approach to solving the problem. -->\nfirst we will assign different components to each node \nas we get a request we will check that do they belong to same component or not, if they belong to different component then we will check that no nodes between these components shoudl lie in restriction edges\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n^2)$$ \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n^2)$$ \n# Code\n```\nclass Solution {\npublic:\n\n    bool dfs(int val, int node,int par, vector<vector<int>>&g,set<pair<int,int>>&st){\n        if(st.find({val,node})!=st.end() || st.find({node,val})!=st.end()) return 0;\n        int ans=1;\n        for(auto i: g[node]) if(i!=par) ans&=dfs(val,i,node,g,st);\n        return ans;\n    }\n\n    bool check(int u,int v,int a,int b,vector<vector<int>>&g,set<pair<int,int>>&st){\n        int ans=dfs(u,v,v,g,st);\n        for(auto i: g[u]){\n            if(i==a) continue;\n            ans&=check(i,v,u,v,g,st);\n        }\n        return ans;\n    }\n\n    void assign(int node,int par,int col,vector<vector<int>>&g,vector<int>&comp){\n        comp[node]=col;\n        for(auto child: g[node]){\n            if(child!=par) assign(child,node,col,g,comp);\n        }\n    }\n\n    vector<bool> friendRequests(int n, vector<vector<int>>& restrictions, vector<vector<int>>& requests) {\n        set<pair<int,int>>st;\n        for(auto i : restrictions) st.insert({i[0],i[1]});\n        vector<int>comp(n);\n        for(int i=0;i<n;i++) comp[i]=i;\n        vector<vector<int>>g(n);\n        vector<bool>ans;\n        for(auto i: requests){\n            int u=i[0],v=i[1];\n            if(st.find({u,v})!=st.end() || st.find({v,u})!=st.end()){\n                ans.push_back(false);\n                continue;\n            }\n            if(comp[u]==comp[v]){\n                ans.push_back(true);\n                continue;\n            }\n\n            if(check(u,v,u,v,g,st)){\n                g[u].push_back(v);\n                g[v].push_back(u);\n                assign(u,v,comp[v],g,comp);\n                ans.push_back(true);\n            }\n            else ans.push_back(false);\n        }\n        return ans;\n    }\n};\n```
['C++']