Count Distinct Elements In Every Window Of Size K

easy
1. You are given an array(arr) of integers and a number K.
2. You have to find the count of distinct numbers in all windows of size k.

Input Format

A number N arr1 arr2.. N numbers A number K

Output Format

Space separated numbers representing the count of distinct numbers in all windows of size k.

Constraints

1 <= N <= 10^5
1 <= arr[i] <= 10^4
1 <= k <= N

Example

Input
7
1 2 1 3 4 2 3        
4
Output
3 4 4 3 
Previous
Largest Subarray With Zero Sum
Next
Largest Subarray With Contiguous Elements

Related Questions