This will be the most complex code u will find. If u understand this u are having a very very great.
Intuition\nThis will be the most complex code u will find.\n\n# Approach\n Describe your approach to solving the problem. \nDFS\n\n# Complexity\n- Time complexi
# Intuition\nThis will be the most complex code u will find.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nDFS\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(n^2)\n\n# Code\n```\nclass Solution {\n    public List<List<Integer>> getAncestors(int n, int[][] e) {\n        ArrayList<Set<Integer>> l=new ArrayList<>();\n        for(int i=0;i<n;i++)\n        {\n            l.add(new TreeSet<>());\n        }\n        for(int[] i:e)\n        {\n            l.get(i[1]).add(i[0]);\n        }\n        ArrayList<Set<Integer>> l1=new ArrayList<>();\n        List<List<Integer>> l2=new ArrayList<>();\n        for(int i=0;i<n;i++)\n        {\n            TreeSet<Integer> s=new TreeSet<>(l.get(i));\n            TreeSet<Integer> s1=new TreeSet<>(l.get(i));\n            TreeSet<Integer> s6=new TreeSet<>();\n            while(s1.size()>0)\n            {\n                TreeSet<Integer> s2=new TreeSet<>(s1);\n                for(int j:s2)\n                {\n                    s.addAll(l.get(j));\n                    s6.add(j);\n                    TreeSet<Integer> s7=new TreeSet<>(l.get(j));\n                    s7.removeAll(s6);\n                    s1.addAll(s7);\n                    s1.remove(j);\n                }\n            }\n            l1.add(s);\n        }\n        for(int i=0;i<n;i++)\n        {\n            List<Integer> l3=new ArrayList<>(l1.get(i));\n            l2.add(l3);\n        }\n        return l2;\n    }\n}\n```
['Java']