Hertz Interview Question

Graph structure and DFS search