Citadel interview question

Graph question based on DFS Behavioral questions