Domanda di colloquio di Exodus

How I would solve a specific algorithm