Amazon interview question

simple BFS approach implementation needed to be coded