Pergunta de entrevista da empresa Ring

Optimization problem, but cannot understand..