Java || DFS || Simple || Explanation
```\n/\n\n    First parameter of the dfs is going to fill itself as the ansester of all the \n    nodes it can traverse in one dfs call\n\n/\n\nclass Solution {
```\n/*\n\n    First parameter of the dfs is going to fill itself as the ansester of all the \n    nodes it can traverse in one dfs call\n\n*/\n\nclass Solution {\n    public List<List<Integer>> getAncestors(int n, int[][] edges) {\n        ArrayList<Integer>[] graph = new ArrayList[n], res = new ArrayList[n];\n        for (int i = 0; i < n; i++) graph[i] = new ArrayList<>();\n        for (int[] e : edges) {\n            graph[e[0]].add(e[1]);\n        }\n        for (int i = 0; i < n; i++) {\n            res[i] = new ArrayList<>();\n        }\n        for (int i = 0; i < n; i++) {\n            boolean[] visited = new boolean[n];\n            dfs(i, i, graph, visited, res);\n        }\n        List<List<Integer>> answer = new ArrayList<>();\n        for (int i = 0; i < n; i++) {\n            answer.add(res[i]);\n        }\n        return answer;\n    }\n    \n    //          originalSource, neighbour, graph, visited\n    public void dfs(int osrc, int next, ArrayList<Integer>[] graph, boolean[] visited,\n                   ArrayList<Integer>[] res) {\n        visited[next] = true;\n        for (int nbr : graph[next]) {\n            if (!visited[nbr]) {\n                res[nbr].add(osrc);\n                dfs(osrc, nbr, graph, visited, res);\n            }\n        }\n    }\n}
[]