[Python3] DFS on Transposed Graph | Help from Hint | Medium
First tried Kahn\'s (twice queue traversal) but failed to implement. \n Took help from the given hint and coded. Hope It is good.\n Please suggest if any improv
* First tried Kahn\'s (twice queue traversal) but failed to implement. \n* Took help from the given hint and coded. Hope It is good.\n* Please suggest if any improvements/advise. (PS : Started giving contest now to improve my time management)\n\n\n\t\t\tg = defaultdict(list)\n\t\t\tfor u, v in edges:\n\t\t\t\tg[v].append(u)               #reversing the edges in adjacency list\n\n\t\t\tdef dfs(node, root):\n\t\t\t\tvis[node] = 1\n\t\t\t\tfor k in g[node]:\n\t\t\t\t\tif vis[k]==0:\n\t\t\t\t\t\tans[root].add(k)\n\t\t\t\t\t\tdfs(k, root)\n\n\t\t\tans = [set() for _ in range(n)]\n\t\t\tfor i in range(n):\n\t\t\t\tvis=[0]*n\n\t\t\t\tdfs(i, i)\n\t\t\treturn [sorted(row) for row in ans]
['Depth-First Search', 'Python3']