DSU || C++
Code\n\nclass DisjointSet \n{\npublic:\n    vector<int> parent, size;\n    DisjointSet(int n) \n    {\n        parent.resize(n);\n        size.resize(n);\n     
# Code\n```\nclass DisjointSet \n{\npublic:\n    vector<int> parent, size;\n    DisjointSet(int n) \n    {\n        parent.resize(n);\n        size.resize(n);\n        for(int x=0; x<n; x++) \n        {\n            parent[x]=x;\n            size[x]=1;\n        }\n    }\n\n    int findPar(int node) \n    {\n        if(node==parent[node]) return node;\n        return parent[node]=findPar(parent[node]);\n    }\n\n    void unionn(int u, int v) \n    {\n        int upar=findPar(u);\n        int vpar=findPar(v);\n        if(upar==vpar) return;\n        if(size[upar]<size[vpar]) \n        {\n            parent[upar]=vpar;\n            size[vpar]+=size[upar];\n        }\n        else \n        {\n            parent[vpar]=upar;\n            size[upar]+=size[vpar];\n        }\n    }\n};\nclass Solution \n{\npublic:\n    vector<bool> friendRequests(int n, vector<vector<int>>& restrictions, vector<vector<int>>& requests) \n    {\n        vector<bool> ans;\n        DisjointSet ds(n);\n        for(auto request: requests)\n        {\n            DisjointSet prev=ds;\n            ds.unionn(request[0],request[1]);\n            bool success=true;\n            for(auto restriction: restrictions)\n            {\n                if(ds.findPar(restriction[0])==ds.findPar(restriction[1]))\n                {\n                    success=false;\n                    break;\n                }\n            }\n            if(success) ans.push_back(true);\n            else\n            {\n                ds=prev;\n                ans.push_back(false);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']