LogiQuest

86. Distinct Elements in Every Window

MediumSliding WindowHash Map

For every window of k consecutive elements, print the number of distinct values in it.

Input format

Line 1: n k Line 2: n integers

Output format

n − k + 1 counts.

Example 1

Input

7 4
1 2 1 3 4 2 3

Output

3 4 4 3

Example 2

Input

3 1
5 5 5

Output

1 1 1

Constraints

1 ≤ k ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.

Loading the MyLoginn IDE…