DSU based approach
Code
# Code
```cpp []
class Solution {
public:
    int findParent(int node, vector<int>& parent) {
        if (node == parent[node])
            return node;
        return parent[node] = findParent(parent[node], parent);
    }
    void Union(int a, int b, vector<int>& parent, vector<int>& size) {
        a = findParent(a, parent);
        b = findParent(b, parent);
        if (a == b)
            return;
        if (size[a] < size[b])
            swap(a, b);
        parent[b] = a;
        size[a] += size[b];
    }
    bool violationFound(vector<vector<int>>& restrictions,
                        vector<int>& parent) {
        for (auto i : restrictions)
            if (findParent(i[0], parent) == findParent(i[1], parent))
                return true;
        return false;
    }
    vector<bool> friendRequests(int n, vector<vector<int>>& restrictions,
                                vector<vector<int>>& requests) {
        int r = requests.size();
        vector<int> parent(n, 0), size(n, 1);
        for (int i = 0; i < n; i++)
            parent[i] = i;
        vector<bool> ans(r, true);
        for (int i = 0; i < r; i++) {
            vector<int> newParent = parent, newSize = size;
            Union(requests[i][0], requests[i][1], newParent, newSize);
            if (violationFound(restrictions, newParent))
                ans[i] = false;
            else
                parent = newParent, size = newSize;
        }
        return ans;
    }
};
```
['C++']