Google Interview Question

DSA Graphs question based on simple dfs