human
Maximum difference between frequency of two elements such that element having greater frequency is also greater | Return the maximum difference between frequencies of any two elements such that element with greater frequency is also greater in value ..
Finding the frequency of each element ..
Sorting the distinct element.
Iterate through all sorted distinct elements . For each distinct element , maintaining the element with minimum frequency than that element and also finding the maximum frequency difference.
Driven Program"
Solution in Python:
 Give me a code to maximum difference between frequency of two elements such that element having greater frequency is also greater and the other steps required?
assistant
#Here is code to maximum difference between frequency of two elements such that element having greater frequency is also greater and the other steps required.
 def maxdiff ( arr , n ) :
	freq = { }
	dist = [ 0 ] * n
	j = 0
	for i in range ( n ) :
		if ( arr [ i ] not in freq ) :
			dist [ j ] = arr [ i ]
			j += 1
			freq [ arr [ i ] ] = 0
		if ( arr [ i ] in freq ) :
			freq [ arr [ i ] ] += 1
	dist = dist [ : j ]
	dist . sort ( )
	min_freq = n + 1
	ans = 0
	for i in range ( j ) :
		cur_freq = freq [ dist [ i ] ]
		ans = max ( ans , cur_freq - min_freq )
		min_freq = min ( min_freq , cur_freq )
	return ans
arr = [ 3 , 1 , 3 , 2 , 3 , 2 ]
n = len ( arr )
print ( maxdiff ( arr , n ) )