human
Give me a code to subsequence pair from given Array having all unique and all same elements respectively and the other steps required given the following:
Subsequence pair from given Array having all unique and all same elements respectively | Function to find the maximum length of subsequences with given property.
To store the frequency.
Traverse the array to store the frequency.
M . size ( ) given count of distinct element in arr [ ].
Traverse map to find max frequency.
Find the maximum length on the basis of two cases in the approach.
Driver Code.
Function call"
Solution in Python:
assistant
#Here is code to subsequence pair from given Array having all unique and all same elements respectively and the other steps required.
 def maximumSubsequence ( arr , N ) :
	M = { i : 0 for i in range ( 100 ) }
	for i in range ( N ) :
		M [ arr [ i ] ] += 1
	distinct_size = len ( M )
	maxFreq = 1
	for value in M . values ( ) :
		maxFreq = max ( maxFreq , value )
	print ( max ( min ( distinct_size , maxFreq - 1 ) , min ( distinct_size - 1 , maxFreq ) ) )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 4 , 4 , 4 , 4 , 5 ]
	N = len ( arr )
	maximumSubsequence ( arr , N )