Pergunta de entrevista da empresa Mathnasium

How would you solve this problem?