✅DSU || cPP
\n# Code\ncpp []\nclass DSU{\n    public:\n    vector<int>size,par;\n    DSU(int n){\n        for(int i=0;i<n;i++){\n            size.push_back(1);\n           
\n# Code\n```cpp []\nclass DSU{\n    public:\n    vector<int>size,par;\n    DSU(int n){\n        for(int i=0;i<n;i++){\n            size.push_back(1);\n            par.push_back(i);\n        }\n\n    }\n    int getP(int i){\n        if(par[i]==i)return i;\n        return par[i]=getP(par[i]);\n    }\n\n    void UnionBySize(int i,int j){\n        if(size[i]>=size[j]){\n            par[j]=i;\n            size[j]+=size[i];\n            return ;\n        }\n        par[i]=j;\n        size[i]+=size[j];\n        return ;\n    }\n};\n\nclass Solution {\npublic:\n    vector<bool> friendRequests(int n, vector<vector<int>>& restrictions, vector<vector<int>>& requests) {\n        vector<vector<int>>dp(n,vector<int>(n,0));\n        DSU arr(n);\n        for(vector<int>v:restrictions){\n            dp[v[0]][v[1]]=1;\n            dp[v[1]][v[0]]=1;\n        }\n        vector<bool>ans;\n        for(vector<int>q:requests){\n            int a=arr.getP(q[0]);\n            int b=arr.getP(q[1]);\n            if(dp[a][b]){\n                ans.push_back(0);\n                continue;\n            }\n            arr.UnionBySize(a,b);\n            for(vector<int>r:restrictions){\n                int a=arr.getP(r[0]);\n                int b=arr.getP(r[1]);\n                dp[a][b]=1;\n                dp[b][a]=1;\n            }\n            ans.push_back(1);\n        }\n        return ans;\n    }\n};\n```
['Union Find', 'Graph', 'C++']