Pergunta de entrevista da empresa Axon

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