Pregunta de entrevista de Amazon

BFS question with a bar raiser Leetcode medium