Akshay loves to play with numbers and arrays. He took an array of size " 2n " where n is any positive integer chose by him. He tries to divide the array into n pairs, such that the pair sum minimizes the maximum sum of a pair.
For example, say we have an array with the given numbers [9, 6, 1, and 5]. The possible pairs are
( 1, 6 ) , ( 5 , 9 ) or ( 1 , 5 )  , ( 6 , 9 ) or  ( 1 , 9 ) , ( 5 , 6 ). The pair sums for these partitions are ( 7, 14 ) and ( 6, 15 ) and ( 10, 11 )  respectively.  The ideal or the selected pairs are (1, 9), (5, 6 )  because out of all the three cases or possibilities we only have (1, 9), (5, 6 )  where the sum of both pairs is a minimum of all the maximum sum of all three possibilities. 
 
Example 1:
Ã¢â¬â¹Input : arr[ ] = {5, 8, 3, 9} and N = 2
Output : 13
Explanation:
Possible pairs: 
(8,9)(3,5) -->Case 1
Sum : (17)(8) --> maximum sum 17
(5,9)(3,8) -->Case 2
Sum : (14)(11) ----> maximum sum 14
(3,9)(5,8) -->Case 3
Sum : (12)(13)--> maximum sum 13
In case 3 , the maximum sum is minimum of 
all the other cases. Hence, the answer is 13.
Example 2:
Input : arr[ ] = {1, 6, 5, 9} and N = 2
Output : 11
Your Task:
This is a function problem. The input is already taken care of by the driver code. You only need to complete the function Pair_minimum() that takes an array (arr), sizeOfArray (n), and return the minimum of all the maximum sum of all possibilities. The driver code takes care of the printing.
Expected Time Complexity: O(N*Log(N)).
Expected Auxiliary Space: O(1).
 
Constraints:
1 ≤ N ≤ 10^{5}
1 ≤ A[2*N] ≤ 10^{5}

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(N*Log(N)).
Expected Auxiliary Space: O(1).

Starter code:
#User function Template for python3

class Solution:
    def Pair_minimum (self, arr, n) : 
        #Complete the function



Solutions:
class Solution:

	def Pair_minimum(self, arr, n):
		arr.sort()
		maxi = 0
		for i in range(n):
			maxi = max(maxi, arr[i] + arr[-i - 1])
		return maxi


class Solution:

	def Pair_minimum(self, arr, n):
		arr.sort()
		i = 0
		j = 2 * n - 1
		res = 0
		while i < j:
			summ = arr[i] + arr[j]
			res = max(res, summ)
			i += 1
			j -= 1
		return res


class Solution:

	def Pair_minimum(self, arr, n):
		arr.sort()
		start = 0
		end = len(arr) - 1
		maxi = -1
		while start < end:
			maxi = max(maxi, arr[start] + arr[end])
			start += 1
			end -= 1
		return maxi


class Solution:

	def Pair_minimum(self, arr, n):
		arr.sort()
		res = 0
		for i in range(n):
			res = max(arr[i] + arr[n * 2 - i - 1], res)
		return res


class Solution:

	def Pair_minimum(self, arr, n):
		arr.sort()
		lis = []
		l = 0
		r = len(arr) - 1
		while l < r:
			lis.append(arr[l] + arr[r])
			l += 1
			r -= 1
		return max(lis)


class Solution:

	def Pair_minimum(self, arr, n):
		arr.sort()
		min1 = arr[0] + arr[len(arr) - 1]
		for i in range(len(arr)):
			min1 = max(min1, arr[i] + arr[len(arr) - i - 1])
		return min1


class Solution:

	def Pair_minimum(self, arr, n):
		arr.sort()
		(m, l) = (0, 0)
		r = 2 * n - 1
		while l < r:
			d = arr[l] + arr[r]
			if d > m:
				m = d
			l += 1
			r -= 1
		return m


class Solution:

	def Pair_minimum(self, arr, n):
		arrays = arr
		array = sorted(arrays)
		a = []
		for i in range(0, len(array) // 2):
			a.append(array[i] + array[len(array) - 1 - i])
		return max(a)