#K33112. Unique Elements Within K-Window

    ID: 25016 Type: Default 1000ms 256MiB

Unique Elements Within K-Window

Unique Elements Within K-Window

Given an integer array and an integer \( k \), determine whether every contiguous subarray (window) of size \( k \) contains all unique elements. In other words, for every consecutive sequence of \( k \) elements from the array, there should be no duplicates. If \( k \) is greater than the size of the array or the array is empty, consider the condition as satisfied (i.e., output True).

Formally, for an array \( nums \) of length \( n \), check whether for every index \( i \) such that \( 0 \leq i \leq n-k \), the subarray \( [nums[i], nums[i+1], \ldots, nums[i+k-1]] \) contains all distinct elements.

inputFormat

The first line contains two integers \( n \) and \( k \), where \( n \) is the number of elements in the array and \( k \) is the window size. The second line contains \( n \) space-separated integers representing the array elements. If \( n \) is zero, the second line will be empty.

outputFormat

Output a single line containing True if every contiguous subarray of length \( k \) has all unique elements; otherwise, output False.

## sample
4 3
1 2 3 1
True

</p>