Hertz interview question

Graph structure and DFS search