#C7065. Max Unique Subarray
Max Unique Subarray
Max Unique Subarray
Given an array of integers and a positive integer k, the task is to find the maximum number of unique integers present in any contiguous subarray (window) of length k. In other words, if you slide a window of size k along the array, determine the maximum count of distinct numbers seen in any such window.
If the size of the array is less than k, the answer should be 0. The problem requires you to read input from standard input and write the result to standard output.
The formula for a window starting at index i is:
[ \text{UniqueCount}_i = #{ arr[j] ;:; i \leq j < i+k }]
Your goal is to compute:
[ \max_{0 \leq i \leq n-k}(\text{UniqueCount}_i) ]
</p>inputFormat
The first line of input contains two integers n and k, where n is the number of elements in the array and k is the size of the subarray.
The second line contains n space-separated integers representing the array.
outputFormat
Output a single integer representing the maximum number of unique integers found in any contiguous subarray of length k.
## sample7 4
1 2 1 3 4 2 3
4