human
Write me a code to minimum delete operations to make all elements of array same and the other steps required given the following:
Minimum delete operations to make all elements of array same | Function to get minimum number of elements to be deleted from array to make array elements equal.
Create an dictionary and store frequencies of all array elements in it using element as key and frequency as value.
Find maximum frequency among all frequencies ..
To minimize delete operations , we remove all elements but the most frequent element ..
Driver code"
How can the above be solved in Python?
assistant
#Here is code to minimum delete operations to make all elements of array same and the other steps required.
 def minDelete ( arr , n ) :
	freq = { }
	for i in range ( n ) :
		if arr [ i ] in freq :
			freq [ arr [ i ] ] += 1
		else :
			freq [ arr [ i ] ] = 1 ;
	max_freq = 0 ;
	for i , j in freq . items ( ) :
		max_freq = max ( max_freq , j ) ;
	return n - max_freq ;
arr = [ 4 , 3 , 4 , 4 , 2 , 4 ] ;
n = len ( arr )
print ( minDelete ( arr , n ) ) ;