Domanda di colloquio di Miro

Algorithmic Problem with explanation of its complexity.