Most Distinct Window
Among all windows of exactly K elements, print the largest number of distinct values any window contains.
Input: the first line has N and K; the second line has N integers.
Output: the maximum count of distinct values in a size-K window.
Constraints:
- 1 ≤ K ≤ N ≤ 104
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
7 3 1 2 1 3 4 2 3
Output 1
3
Input 2
3 3 5 5 5
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.