human
Number of pairs with maximum sum | Python program to count pairs with maximum sum.
traverse through all the pairs.
traverse through all pairs and keep a count of the number of maximum pairs.
driver code"
How can the above be solved in Python?
assistant
#Here is code to number of pairs with maximum sum and the other steps required.
 def _sum ( a , n ) :
	maxSum = - 9999999
	for i in range ( n ) :
		for j in range ( n ) :
			maxSum = max ( maxSum , a [ i ] + a [ j ] )
	c = 0
	for i in range ( n ) :
		for j in range ( i + 1 , n ) :
			if a [ i ] + a [ j ] == maxSum :
				c += 1
	return c
array = [ 1 , 1 , 1 , 2 , 2 , 2 ]
n = len ( array )
print ( _sum ( array , n ) )