human
Pair with largest sum which is less than K in the array | Function to find pair with largest sum which is less than K in the array.
To store the break point.
Sort the given array.
Find the break point.
No need to look beyond i 'th index.
Find the required pair.
Print the required answer.
Driver code.
Function call"
Solution in Python:
 ... Can you provide a code to pair with largest sum which is less than K in the array and the other steps required?
assistant
#Here is code to pair with largest sum which is less than K in the array and the other steps required.
 def Max_Sum ( arr , n , k ) :
	p = n
	arr . sort ( )
	for i in range ( 0 , n ) :
		if ( arr [ i ] >= k ) :
			p = i
			break
	maxsum = 0
	a = 0
	b = 0
	for i in range ( 0 , p ) :
		for j in range ( i + 1 , p ) :
			if ( arr [ i ] + arr [ j ] < k and arr [ i ] + arr [ j ] > maxsum ) :
				maxsum = arr [ i ] + arr [ j ]
				a = arr [ i ]
				b = arr [ j ]
	print ( a , b )
arr = [ 5 , 20 , 110 , 100 , 10 ]
k = 85
n = len ( arr )
Max_Sum ( arr , n , k )