Pergunta de entrevista da empresa MIT

How did you solve this problem?