Google interview question

DSA Graphs question based on simple dfs