human
Difference between highest and least frequencies in an array | Python3 code to find the difference between highest nd least frequencies.
sort the array.
checking consecutive elements.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to difference between highest and least frequencies in an array and the other steps required.
 def findDiff ( arr , n ) :
	arr . sort ( )
	count = 0 ; max_count = 0 ; min_count = n
	for i in range ( 0 , ( n - 1 ) ) :
		if arr [ i ] == arr [ i + 1 ] :
			count += 1
			continue
		else :
			max_count = max ( max_count , count )
			min_count = min ( min_count , count )
			count = 0
	return max_count - min_count
arr = [ 7 , 8 , 4 , 5 , 4 , 1 , 1 , 7 , 7 , 2 , 5 ]
n = len ( arr )
print ( findDiff ( arr , n ) )