← ALL NOTES
Array

2958. Length of Longest Subarray With at Most K Frequency

Only the element you just appended can push a count above k, so the window stays valid the moment you shrink it enough to fix that one value.

Loading…