Google interview question

Graph dfs and bfs problem