C++ || EASY TO UNDERSTAND || DSU IMPLEMENTATION
\nclass dsu {\n    int *rank, *parent, n;\n \npublic:\n    dsu(int n)\n    {\n        rank = new int[n];\n        parent = new int[n];\n        this->n = n;\n  
```\nclass dsu {\n    int *rank, *parent, n;\n \npublic:\n    dsu(int n)\n    {\n        rank = new int[n];\n        parent = new int[n];\n        this->n = n;\n        makeSet();\n    }\n    void makeSet()\n    {\n        for (int i = 0; i < n; i++) {\n            parent[i] = i;\n        }\n    }\n \n    int par(int x)\n    {\n        if (parent[x] != x) {\n            parent[x] = par(parent[x]);\n        }\n        return parent[x];\n    }\n    void unions(int x, int y)\n    {\n        int xset = par(x);\n        int yset = par(y);\n        if (xset == yset)\n            return;\n        if (rank[xset] < rank[yset]) {\n            parent[xset] = yset;\n        }\n        else if (rank[xset] > rank[yset]) {\n            parent[yset] = xset;\n        }\n        else {\n            parent[yset] = xset;\n            rank[xset] = rank[xset] + 1;\n        }\n    }\n};\n \n\nclass Solution {\npublic:\n    vector<bool> friendRequests(int n, vector<vector<int>>& res, vector<vector<int>>& req) {\n        dsu obj(n);\n        obj.makeSet();\n        vector<bool> ans;\n        for(int i = 0; i < req.size();i++){\n   int x= obj.par(req[i][0]);\n                int y = obj.par(req[i][1]);\n            bool b = true;\n            for(int j = 0; j < res.size();j++){\n                int x1 = obj.par(res[j][0]);\n                int y1 = obj.par(res[j][1]);\n                if((x==x1&&y==y1)||(x==y1&&y==x1)){\n                    b = false;\n                    break;\n                }\n            }\n            if(b){\n                ans.push_back(true);\n                obj.unions(req[i][0],req[i][1]);\n            }\n            else{\n                ans.push_back(false);\n            }\n        }\n        return ans;\n    }\n};\n```
['Union Find', 'C', 'C++']