Count the Specials
Submissions: 8939   Accuracy:


  Difficulty: Easy   Marks: 2
Associated Course(s):   Fork CPP

Given an array A (may contain duplicates) of N elements and a positive integer K. The task is to count the number of elements which occurs exactly floor(N/K) times in the array.

First line of input contains number of testcases. For each testcase, there will be two lines, first of which contains N and K and second line contains array elements.

For each testcase, print the count of elements in the array which occurs exactly floor(N/K) times.

1 <= T <= 100
1 <= N <= 103
1 <= Ai <= 103

1 <= K <= 103

User Task:
Your task is to complete the function countSpecials() which should count the elements which occurs exactly floor(N/K) times.


5 2
1 4 1 2 4


Testcase 1:
In the given array, 1 and 4 occurs floor(5/2) = 2 times. So count is 2.

** For More Input/Output Examples Use 'Expected Output' option **

Author: Dhiman Mayank

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.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.