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.
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.