Amazon Interview Question

graph traversal question, that is dfs and bfs