Count distinct numbers

Given an array of size n and an integer k, print the count of distinct numbers in all windows of size k.

First window is from index 0 to k-1, then 2nd window is from 1 to k, 3rd window is from 2 to k+1 and so on.

Input format :

Line 1 : Array size (n)

Line 2 : Array elements (separated by space)

Line 3 : k

Output format : Count of numbers for each window in different line

Sample Input :
8    
2 1 5 2 4 3 3 6         
4
Sample Output :
3
4
4
3
3

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem