Associated Course(s):
Must Do Interview Preparation
Sudo Placement 2019

Given an array **A[]** of size **N** and an integer **K**. Your task is to complete the function **countDistinct**() which prints the count of distinct numbers in all windows of size k in the array A[].

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains two integers N and K. Then in the next line are N space separated values of the array A[].

**Output:**

For each test case in a new line print the space separated values denoting counts of distinct numbers in all windows of size k in the array A[].

**Constraints:**

1 <= T <= 100

1 <= N, K <= 100

1 <= A[] <= 100

**Example(To be used only for expected output):**

**Input:**

2

7 4

1 2 1 3 4 2 3

3 2

4 1 1

**Output:**

3 4 4 3

2 1

**Note:**The **Input/Ouput** format and **Example** given are used for system's internal purpose, and should be used by a user for **Expected Output** only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

thanuvinu94 | 425 |

the_coder95 | 380 |

RishabhTanwar1 | 280 |

shubham3174 | 208 |

RitikRosan | 202 |

the_coder95 | 1226 |

RishabhTanwar1 | 1000 |

thanuvinu94 | 634 |

tathagat289 | 628 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4885 |

Quandray | 4547 |

Login to report an issue on this page.