C++ | DFS | Easy to understand
```\n\nclass Solution {\npublic:\n    void dfs(vectorg[], vector& vis, int node){\n        if(vis[node]==true) return;\n        vis[node] = true;\n        for(a
```\n\nclass Solution {\npublic:\n    void dfs(vector<int>g[], vector<bool>& vis, int node){\n        if(vis[node]==true) return;\n        vis[node] = true;\n        for(auto x:g[node]){\n            if(vis[x]==false){\n                dfs(g, vis, x);\n            }\n        }\n    }\n    vector<vector<int>> getAncestors(int n, vector<vector<int>>& edges) {\n        vector<int>g[n];\n        for(auto x:edges){\n            g[x[1]].push_back(x[0]);\n        }\n        vector<vector<int>>ans;\n        \n        for(int i=0;i<n;i++){\n            vector<bool>vis(n, false);\n            dfs(g, vis, i);\n            vector<int>v;\n            for(int j=0;j<n;j++){\n                if(vis[j]==true and j!=i){\n                    v.push_back(j);\n                }\n            }\n            ans.push_back(v);\n        }\n        return ans;\n    }\n};
['Depth-First Search', 'C', 'C++']