Bloomberg interview question

BFS/DFS related graph traversal question