Bloomberg Interview Question

BFS/DFS related graph traversal question