Standard Chartered Bank interview question

graph question based on dfs.