human
Minimum value of " max ▁ + ▁ min " in a subarray | Python 3 program to find sum of maximum and minimum in any subarray of an array of positive numbers ..
Driver code"
How can the above be solved in Python?
assistant
#Here is code to minimum value of " max ▁ + ▁ min " in a subarray and the other steps required.
 def maxSum ( arr , n ) :
	if ( n < 2 ) :
		return - 1
	ans = arr [ 0 ] + arr [ 1 ]
	for i in range ( 1 , n - 1 , 1 ) :
		ans = min ( ans , ( arr [ i ] + arr [ i + 1 ] ) )
	return ans
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 12 , 2 , 2 ]
	n = len ( arr )
	print ( maxSum ( arr , n ) )