Pergunta de entrevista da empresa Buckhill

Algorithm question, can't remember which one