Intuition Explained || Straight Forward DSU || C++ Clean Code
Code: \n\n\n// Standard DSU Class\nclass DSU {\n    vector<int> parent, size;\npublic: \n    \n    DSU(int n) {\n        for(int i=0; i<=n; i++) {\n            
# Code: \n\n```\n// Standard DSU Class\nclass DSU {\n    vector<int> parent, size;\npublic: \n    \n    DSU(int n) {\n        for(int i=0; i<=n; i++) {\n            parent.push_back(i);\n            size.push_back(1);\n        }\n    }\n    \n    int findParent(int num) {\n        if(parent[num] == num) return num;\n        return parent[num] = findParent(parent[num]);\n    }\n    \n\t// Directly getting parents of u and v\n\t// To avoid finding parent multiple times\n    void unionBySize(int parU, int parV) {\n        \n        if(size[parU] < size[parV]) {\n            size[parV] += size[parU];\n            parent[parU] = parV;\n        }\n        else {\n            size[parU] += size[parV];\n            parent[parV] = parU;\n        }\n    }\n};\n\nclass Solution {\npublic:\n    vector<bool> friendRequests(int n, vector<vector<int>>& restrictions, vector<vector<int>>& requests) {\n        \n        DSU dsu(n);\n        \n        vector<bool> successful;\n        \n        for(auto& request : requests) {\n            \n            int u = request[0], v = request[1];\n            \n            int parU = dsu.findParent(u), parV = dsu.findParent(v);\n            \n            bool flag = true;\n            \n            if(parU != parV) {\n                \n\t\t\t\t// Check if current friend requested is restricted or not.\n                for(auto& restriction : restrictions) {\n                    int restricted_U = restriction[0], restricted_V = restriction[1];\n                    \n                    int restricted_parU = dsu.findParent(restricted_U);\n                    int restricted_parV = dsu.findParent(restricted_V);\n                    \n                    if((parU == restricted_parU && parV == restricted_parV) || (parU == restricted_parV && parV == restricted_parU)) {\n                        flag = false;\n                        break;\n                    }\n                }\n                \n\t\t\t\t// Union u and v by passing parents\n\t\t\t\t// Since it is already calculated above\n                if(flag) {\n                    dsu.unionBySize(parU, parV);\n                }\n            }\n            \n            successful.push_back(flag);\n        }\n        \n        return successful;\n    }\n};\n```
['Union Find', 'C']