[Python] Short & Easy DFS
First create the mapping between each node and its direct parent.\nThen for each node do depth first to gather all of its parents (removing duplicates with set)
First create the mapping between each node and its direct parent.\nThen for each node do depth first to gather all of its parents (removing duplicates with set)\n```\nclass Solution:\n    def getAncestors(self, n, edges):\n        ancestors = defaultdict(list)\n        for a, b in edges:\n            ancestors[b].append(a)\n        \n        @lru_cache(None)\n        def dfs(i):\n            res = set(ancestors[i])\n            for x in ancestors[i]:\n                res |= dfs(x)\n            return res\n        return [sorted(dfs(i)) for i in range(n)]\n```
[]