Problem 2841 · Medium

Maximum Sum of Almost Unique Subarray

Slide a window of length k, track each value with a tally, and keep the largest sum whose window holds at least m distinct values.

Open the interactive visualisation