TikTok Interview Question

question on graphs, BFS, DFS