Leetcode 992. Subarrays with K Different Integers
Count the number of contiguous subarrays that contain exactly k distinct integers. A common approach is to use two-pointer/sliding-window with a frequency map to compute “at most K” minus “at most K−1” subarray counts in linear time.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Your account is free and you can post anonymously if you choose.