human
Write me a code to print all the sum pairs which occur maximum number of times and the other steps required given the following:
Print all the sum pairs which occur maximum number of times | Function to find the sum pairs that occur the most.
Hash - table.
Keep a count of sum pairs.
Variables to store maximum occurrence.
Iterate in the hash table.
Print all sum pair which occur maximum number of times.
Driver code"
Solution in Python:
assistant
#Here is code to print all the sum pairs which occur maximum number of times and the other steps required.
 def findSumPairs ( a , n ) :
	mpp = { i : 0 for i in range ( 21 ) }
	for i in range ( n - 1 ) :
		for j in range ( i + 1 , n , 1 ) :
			mpp [ a [ i ] + a [ j ] ] += 1
	occur = 0
	for key , value in mpp . items ( ) :
		if ( value > occur ) :
			occur = value
	for key , value in mpp . items ( ) :
		if ( value == occur ) :
			print ( key )
if __name__ == ' _ _ main _ _ ' :
	a = [ 1 , 8 , 3 , 11 , 4 , 9 , 2 , 7 ]
	n = len ( a )
	findSumPairs ( a , n )