[C++] Simple C++ Code || 90% time || union find
\n# If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\n    v
\n# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\n    vector<int> parents;\n    int find_set(int v)\n    {\n        if(v == parents[v])\n            return v;\n        return parents[v] = find_set(parents[v]);\n    }\n    void union_set(int a, int b)\n    {\n        a = find_set(a);\n        b = find_set(b);\n        if(a == b)\n            return;\n        if(a != b)\n            parents[b] = a;\n        return;\n    }\npublic:\n    vector<bool> friendRequests(int n, vector<vector<int>>& restrictions, vector<vector<int>>& requests) {\n        for(int i = 0; i < n; i++)\n            parents.push_back(i);\n        vector<bool> ans;\n        for(vector<int> &req : requests)\n        {\n            int v = 1;\n            int a = find_set(req[0]);\n            int b = find_set(req[1]);\n            for(vector<int> &res : restrictions)\n            {\n                int r1 = find_set(res[0]);\n                int r2 = find_set(res[1]);\n                if((a == r1 && b == r2) || (b == r1 && a == r2))\n                {\n                    v = 0;\n                    break;\n                }\n            }\n            ans.push_back(v);\n            if(v)\n            {\n                union_set(a,b);\n            }\n        }\n        return ans;\n    }\n};\n```
['Union Find', 'C', 'C++']