Pergunta de entrevista da empresa Miro

Algorithmic Problem with explanation of its complexity.