human
Print all array elements appearing more than N / K times | Function to prall array elements whose frequency is greater than N / K.
Sort the array , arr [ ].
Traverse the array.
Stores frequency of arr [ i ].
Traverse array elements which is equal to arr [ i ].
Update cnt.
Update i.
If frequency of arr [ i ] is greater than ( N / K ).
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to print all array elements appearing more than N / K times and the other steps required.
 def NDivKWithFreq ( arr , N , K ) :
	arr = sorted ( arr )
	i = 0
	while i < N :
		cnt = 1
		while ( ( i + 1 ) < N and arr [ i ] == arr [ i + 1 ] ) :
			cnt += 1
			i += 1
		if ( cnt > ( N // K ) ) :
			print ( arr [ i ] , end = " ▁ " )
		i += 1
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 2 , 6 , 6 , 6 , 6 , 7 , 10 ]
	N = len ( arr )
	K = 4
	NDivKWithFreq ( arr , N , K )