Pregunta de entrevista de Navan

It was a BFS type question.