Domanda di colloquio di MathWorks

Pretty simple algorithm based question