Pregunta de entrevista de Axon

The question was a code problem that could be solved by a breadth first search.