TikTok interview question

question on graphs, BFS, DFS