human
Minimum changes required to make all element in an array equal | Function to count of minimum changes required to make all elements equal.
Store the count of each element as key - value pair in Dictionary.
Traverse through the Dictionary and find the maximum occurring element.
Return count of all element minus count of maximum occurring element.
Driver code.
Function call"
How can the above be solved in Python?
assistant
#Here is code to minimum changes required to make all element in an array equal and the other steps required.
 def minChanges ( arr , n ) :
	mp = dict ( )
	for i in range ( n ) :
		if arr [ i ] in mp . keys ( ) :
			mp [ arr [ i ] ] += 1
		else :
			mp [ arr [ i ] ] = 1
	maxElem = 0
	for x in mp :
		maxElem = max ( maxElem , mp [ x ] )
	return n - maxElem
arr = [ 2 , 3 , 3 , 4 ]
n = len ( arr )
print ( minChanges ( arr , n ) )