Amazon Interview Question

simple BFS approach implementation needed to be coded