CPP || Brute Force Accepted.
```\nclass Solution {\npublic:\n   \n    void dfs(int i,int ansc,vector>&ans,vector&vis,vector>&res){\n             \n        vis[i]=1;\n        \n        for(a
```\nclass Solution {\npublic:\n   \n    void dfs(int i,int ansc,vector<vector<int>>&ans,vector<int>&vis,vector<vector<int>>&res){\n             \n        vis[i]=1;\n        \n        for(auto t:ans[i]){\n            if(!vis[t]){\n                dfs(t,ansc,ans,vis,res);\n            }\n        }\n       \n        if(i!=ansc)\n            res[i].push_back(ansc);\n    }\n    \n    vector<vector<int>> getAncestors(int n, vector<vector<int>>& edges) {\n        \n        vector<vector<int>>ans(n),result(n);\n        \n        for(auto a:edges){\n            ans[a[0]].push_back(a[1]);\n        }\n        \n        for(int i=0;i<n;i++){\n            vector<int>visited(n);\n            dfs(i,i,ans,visited,result);\n        }\n      \n        return result;\n    }\n};
['C++']