Amazon Interview Question

Question which could be represented as a graph, and the solution involved implementing bfs to arrive at the answer