Timer is Running

Given an arry 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.
Hint: You may use hashing or brute-force.

Example 1:

Input:
5 2
1 4 1 2 4

Output:
2

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

Example 2:

Input:
3 2
99 66 66 

Output:
1

Explanation:
In the given array, 99 occurs floor(3/2) = 1 time. So count is 1.

Constrains:
1 <= N <= 103
1 <= Ai <= 103

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

** 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 ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.