[Python3, Java, C++] Simple DFS O(n ^ 2)
Explanation:\n DFS on each node x\n For every node ch that is found after node x in dfs, add x as parent of ch\n\nSteps:\n Record the direct children of each no
**Explanation**:\n* DFS on each node `x`\n* For every node `ch` that is found after node `x` in dfs, add `x` as parent of `ch`\n\n**Steps**:\n* Record the direct children of each node in a graph. Can be implemented using nested vectors or hashmap of lists.\n* Run DFS for each node in graph\n* For every subsequent node that is found after dfs starting from x, add x as parent of subsequent node in ans\n\n*If dfs from x is like:*\n\n```\n                       x\n\t\t\t\t\t  /  \\\n\t\t\t\t\t 3    5\n\t\t\t\t\t |    | \\\n\t\t\t\t\t 1    8  0 \n\t\t\t\t\t\n```\n*x is added as parent for 3, 5, 1, 8, 0*\n\n<iframe src="https://leetcode.com/playground/JQFvFjdu/shared" frameBorder="0" width="750" height="400"></iframe>
['Depth-First Search', 'C', 'Python', 'Java']