Ring interview question

Optimization problem, but cannot understand..