human
Length of array pair formed where one contains all distinct elements and other all same elements | Function to find the max size possible.
Counting the maximum frequency.
Counting total distinct elements.
Find max of both the answer.
Driver code"
How can the above be solved in Python?
 ... Give me a code to length of array pair formed where one contains all distinct elements and other all same elements and the other steps required?
assistant
#Here is code to length of array pair formed where one contains all distinct elements and other all same elements and the other steps required.
 def findMaxSize ( a , n ) :
	frq = [ 0 ] * ( n + 1 )
	for i in range ( n ) :
		frq [ a [ i ] ] += 1
	maxfrq = max ( frq )
	dist = n + 1 - frq . count ( 0 )
	ans1 = min ( maxfrq - 1 , dist )
	ans2 = min ( maxfrq , dist - 1 )
	ans = max ( ans1 , ans2 )
	return ans
arr = [ 4 , 2 , 4 , 1 , 4 , 3 , 4 ]
n = len ( arr )
print ( findMaxSize ( arr , n ) )