Easiest Solution || Disjoint Set || Beats 100% || C++
Complexity\n- Time complexity:O(n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity:$$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass DisjointSet{\n   vector<int> rank, size, parent;\npublic:\n   DisjointSet(int n){\n     rank.resize(n+1,0);\n     size.resize(n+1,0);\n     parent.resize(n+1);\n     for(int i=0; i<=n; i++){\n        parent[i] = i;\n       size[i] = 1;\n     }\n   }\n   int findPar(int node){\n     if(node == parent[node])\n       return node;\n     return parent[node] = findPar(parent[node]);\n   }\n\n   void unionByRank(int u, int v){\n     int ulp_u = findPar(u);\n     int ulp_v = findPar(v);\n\n     if(ulp_u == ulp_v) return;\n     if(rank[ulp_u] < rank[ulp_v]){\n       parent[ulp_u] = ulp_v;\n     }else if(rank[ulp_u] > rank[ulp_v]){\n       parent[ulp_v] = ulp_u;\n     }else{\n       parent[ulp_v] = ulp_u;\n       rank[ulp_u]++;\n     }\n   }\n\n   void unionBySize(int u, int v){\n     int ulp_u = findPar(u);\n     int ulp_v = findPar(v);\n\n     if(ulp_u == ulp_v) return;\n     if(size[ulp_u] < size[ulp_v]){\n       parent[ulp_u] = ulp_v;\n       size[ulp_v] += size[ulp_u];\n     }else{\n       parent[ulp_v] = ulp_u;\n       size[ulp_u] += size[ulp_v];\n     }\n   }\n};\n\nclass Solution {\npublic:\n    vector<bool> friendRequests(int n, vector<vector<int>>& res, vector<vector<int>>& req) {\n        DisjointSet dsu(n);\n        int a = res.size(), b = req.size();\n        vector<bool> ans(b, false);\n        for(int i=0; i<b; i++){\n            int upa = dsu.findPar(req[i][0]), upb = dsu.findPar(req[i][1]);\n            bool fg = true;\n            for(int j=0; j<a; j++){\n                int vpa = dsu.findPar(res[j][0]), vpb = dsu.findPar(res[j][1]);\n                if(vpa == upa && vpb == upb || vpa == upb && vpb == upa){\n                    fg = false;\n                    break;\n                }\n            }\n            if(fg){\n                ans[i] = fg;\n                dsu.unionByRank(req[i][0], req[i][1]);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']