Problem 644 · Hard

Maximum Average Subarray II

Binary search on the answer: subtract a guessed average and check for a long enough subarray with a non-negative sum.

Open the interactive visualisation