Check if element exist in etms[] if not, insert it with the count 1 and if exist then increase its count.

Also check if etms[] gets full when inserting an element, if it is not, follow the previous step. If it is full then reduce the count of every existing element in the etms[]. (Just think of a Tetris game, when row gets full, it gets deleted and size of the Tetris reduced by 1) see the picture below.

Once all the elements of array gets over, check every element of etms[] with array and print those elements which has N/K times.

Find All Elements in an Array which appears more than NbyK times

Complete Code:

Output:

4 appears more than n/4 times, Actual count is 5
3 appears more than n/4 times, Actual count is 4