Search
⌘K

Leetcode 2958. Length of Longest Subarray With at Most K Frequency

Find the maximum-length contiguous subarray of nums such that every distinct element appears at most k times. This is a sliding-window / frequency-counting problem on an array of length up to 1e5, solvable in O(n) time using a running count of element frequencies.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.