1plusX interview question

Algorithmic question that required a monotonic queue for the optimal solution.