Pergunta de entrevista da empresa BaxEnergy

A very simple algorithm question.