Given an array A of size N of integers. Your task is to find the sum of minimum and maximum element in the array.
Example 1:
Input:
N = 5
A[] = {-2, 1, -4, 5, 3}
Output: 1
Explanation: min = -4, max =  5. Sum = -4 + 5 = 1
 
Example 2:
Input:
N = 4
A[]  = {1, 3, 4, 1}
Output: 5
Explanation: min = 1, max = 4. Sum = 1 + 4 = 5
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function findSum() which takes the array A[] and its size N as inputs and returns the summation of minimum and maximum element of the array.
 
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 10^{5}
-10^{9} <= A_{i} <= 10^{9}

Difficulty: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
class Solution:

    def findSum(self,A,N): 

        #code here



Solutions:
class Solution:

	def findSum(self, A, N):
		A.sort()
		return A[0] + A[len(A) - 1]


class Solution:

	def findSum(self, A, N):
		return max(A) + min(A)


class Solution:

	def findSum(self, A, N):
		maxval = A[0]
		minval = maxval
		for i in range(1, N):
			if A[i] > maxval:
				maxval = A[i]
				continue
			if A[i] < minval:
				minval = A[i]
				continue
		return minval + maxval


class Solution:

	def findSum(self, A, N):
		self.A = A
		self.N = N
		max_val = max(A)
		min_val = min(A)
		return max_val + min_val


class Solution:

	def findSum(self, A, N):
		A.sort()
		sum = A[0] + A[N - 1]
		return sum


class Solution:

	def findSum(self, A, N):
		a = min(A)
		b = max(A)
		return a + b


class Solution:

	def findSum(self, arr, arr_size):
		max = 0
		min = 0
		i = 0
		if arr_size % 2 == 1:
			max = arr[0]
			min = arr[0]
			i = 1
		else:
			if arr[0] < arr[1]:
				max = arr[1]
				min = arr[0]
			else:
				max = arr[0]
				min = arr[1]
			i = 2
		while i < arr_size:
			if arr[i] < arr[i + 1]:
				if arr[i] < min:
					min = arr[i]
				if arr[i + 1] > max:
					max = arr[i + 1]
			else:
				if arr[i] > max:
					max = arr[i]
				if arr[i + 1] < min:
					min = arr[i + 1]
			i = i + 2
		return max + min


class Solution:

	def findSum(self, A, N):
		a = A[0]
		b = A[0]
		for i in range(N):
			if a > A[i]:
				a = A[i]
			if b < A[i]:
				b = A[i]
		return a + b


class Solution:

	def findSum(self, A, N):
		d = min(A)
		m = max(A)
		result = d + m
		return result


class Solution:

	def findSum(self, A, N):
		min = 99999999
		max = -999999
		for i in range(0, N):
			if A[i] < min:
				min = A[i]
			if A[i] > max:
				max = A[i]
		return max + min


class Solution:

	def findSum(self, A, N):
		min_a = 10 ** 9
		max_b = -10 ** 9
		for i in range(len(A)):
			if a[i] > max_b:
				max_b = a[i]
			if a[i] < min_a:
				min_a = a[i]
		return min_a + max_b


class Solution:

	def findSum(self, A, N):
		largest_element = A[0]
		for i in range(N):
			if A[i] > largest_element:
				largest_element = A[i]
		smallest_element = A[0]
		for i in range(N):
			if A[i] < smallest_element:
				smallest_element = A[i]
		return largest_element + smallest_element


class Solution:

	def findSum(self, A, N):
		maxx = -10000000
		minn = 10000000
		for i in range(N):
			if A[i] > maxx:
				maxx = A[i]
			if A[i] < minn:
				minn = A[i]
		return maxx + minn


class Solution:

	def findSum(self, A, N):
		Amax = Amin = A[0]
		for i in range(1, N):
			if A[i] > Amax:
				Amax = A[i]
			elif A[i] < Amin:
				Amin = A[i]
		return Amax + Amin


class Solution:

	def findSum(self, A, N):
		ma = -999999999
		mi = 9999999999
		for i in range(N):
			if A[i] < mi:
				mi = A[i]
			if ma < A[i]:
				ma = A[i]
		return ma + mi


class Solution:

	def findSum(self, arr, n):
		maxi = arr[0]
		mini = arr[0]
		for i in range(1, n):
			if arr[i] > maxi:
				maxi = arr[i]
			if arr[i] < mini:
				mini = arr[i]
		return maxi + mini


class Solution:

	def findSum(self, A, N):
		min_elem = A[0]
		max_elem = A[0]
		for i in range(1, N):
			if A[i] < min_elem:
				min_elem = A[i]
			elif A[i] > max_elem:
				max_elem = A[i]
		return min_elem + max_elem


class Solution:

	def findSum(self, A, N):
		min = A[0]
		max = A[0]
		for x in A:
			if x < min:
				min = x
			elif x > max:
				max = x
		return max + min


class Solution:

	def findSum(self, A, N):
		maxi = A[0]
		mini = A[0]
		for i in range(N):
			if A[i] >= maxi:
				maxi = A[i]
			if A[i] <= mini:
				mini = A[i]
		return mini + maxi


class Solution:

	def findSum(self, A, N):
		max = A[0]
		min = A[0]
		for i in A:
			if i > max:
				max = i
		for i in A:
			if i < min:
				min = i
		return max + min


class Solution:

	def findSum(self, A, N):
		index = 0
		minimum = A[0]
		maximum = A[0]
		while index < N:
			if minimum > A[index]:
				minimum = A[index]
			if maximum < A[index]:
				maximum = A[index]
			index += 1
		return maximum + minimum


class Solution:

	def findSum(self, arr, N):
		arr.sort()
		return arr[0] + arr[N - 1]


class Solution:

	def findSum(self, arr, N):
		return max(arr) + min(arr)


class Solution:

	def findSum(self, A, N):
		min_num = max_num = A[0]
		for i in range(1, N):
			if A[i] < min_num:
				min_num = A[i]
			elif A[i] > max_num:
				max_num = A[i]
		return min_num + max_num


class Solution:

	def findSum(self, A, N):
		newarray = sorted(A)
		firstelement = newarray[0]
		lastelement = newarray[-1]
		sumofelement = firstelement + lastelement
		return sumofelement


class Solution:

	def findSum(self, A, N):
		max_a = max(A)
		min_a = min(A)
		sum_a = max_a + min_a
		return sum_a


class Solution:

	def findSum(self, A, N):
		max1 = max(A)
		min1 = min(A)
		return max1 + min1


class Solution:

	def findSum(self, A, N):
		min_val = max_val = A[0]
		for num in A:
			if num < min_val:
				min_val = num
			elif num > max_val:
				max_val = num
		return min_val + max_val


class Solution:

	def findSum(self, A, N):

		def maxMin(A):
			(max, min) = (float('-inf'), float('inf'))
			for i in A:
				if i > max:
					max = i
				if i < min:
					min = i
			return [min, max]
		return sum(maxMin(A))


import numpy as np

class Solution:

	def findSum(self, A, N):
		Ar = np.array(A)
		Ar.sort()
		return Ar[0] + Ar[N - 1]


class Solution:

	def findSum(self, A, N):
		min_val = float('inf')
		max_val = float('-inf')
		for i in range(N):
			if A[i] < min_val:
				min_val = A[i]
			if A[i] > max_val:
				max_val = A[i]
		sum_val = min_val + max_val
		return sum_val


class Solution:

	def findSum(self, A, N):
		x = max(A)
		y = min(A)
		return x + y


class Solution:

	def findSum(self, A, N):
		minimum = A[0]
		maximum = A[0]
		sum = 0
		for x in range(0, len(A), +1):
			if A[x] < minimum:
				minimum = A[x]
			elif A[x] > maximum:
				maximum = A[x]
			sum = maximum + minimum
		return sum


class Solution:

	def findSum(self, A, N):
		min = A[0]
		max = A[0]
		sum = 0
		for x in range(0, len(A), +1):
			if A[x] < min:
				min = A[x]
			elif A[x] > max:
				max = A[x]
		sum = min + max
		return sum


class Solution:

	def findSum(self, A, N):
		maximum = max(A)
		minimum = min(A)
		Sum = minimum + maximum
		return Sum


class Solution:

	def findSum(self, A, N):
		m = min(A)
		n = max(A)
		return m + n


class Solution:

	def findSum(self, A, N):
		s = sorted(A)
		low = s[0]
		high = s[n - 1]
		result = low + high
		return result


class Solution:

	def findSum(self, A, N):
		c = max(a)
		d = min(a)
		s = c + d
		return s


class Solution:

	def findSum(self, A, N):
		maxele = -float('inf')
		for i in range(N):
			if maxele < A[i]:
				maxele = A[i]
		minele = float('inf')
		for i in range(N):
			if minele > A[i]:
				minele = A[i]
		return maxele + minele


class Solution:

	def findSum(self, A, N):
		min = A[0]
		max = A[0]
		for i in range(0, len(A)):
			if A[i] < min:
				min = A[i]
			if A[i] > max:
				max = A[i]
		sum = max + min
		return sum


class Solution:

	def findSum(self, A, N):
		if N == 0:
			return Null
		else:
			return min(A) + max(A)


class Solution:

	def findSum(self, A, N):
		min_elem = float('inf')
		max_elem = float('-inf')
		for i in range(N):
			if A[i] < min_elem:
				min_elem = A[i]
			if A[i] > max_elem:
				max_elem = A[i]
		return min_elem + max_elem


class Solution:

	def findSum(self, A, N):
		import math
		min = math.inf
		max = -math.inf
		for i in range(0, len(A)):
			if A[i] < min:
				min = A[i]
			if A[i] > max:
				max = A[i]
		return max + min


class Solution:

	def findSum(self, A, N):
		s = A[0]
		l = A[0]
		for i in range(N):
			if s > A[i]:
				s = A[i]
			if l < A[i]:
				l = A[i]
		return l + s


class Solution:

	def findSum(self, A, N):
		if N == 1:
			sum = A[0] + A[0]
			return sum
		else:
			(min, max) = (A[0], A[0])
			for i in range(N):
				if A[i] < min:
					min = A[i]
				elif A[i] > max:
					max = A[i]
			sum = min + max
		return sum


class Solution:

	def findSum(self, a, n):
		e = min(a)
		b = max(a)
		return e + b


class Solution:

	def findSum(self, A, N):
		mini = min(A)
		maxi = max(A)
		return mini + maxi


class Solution:

	def findSum(self, A, N):
		l = min(A)
		g = max(A)
		s = 0
		s = int(l + g)
		return s


class Solution:

	def findSum(self, A, N):
		Z = max(A)
		X = min(A)
		sum = Z + X
		return sum


class Solution:

	def findSum(self, A, N):
		mx = max(A)
		mn = min(A)
		s = mx + mn
		return s


class Solution:

	def findSum(self, A, N):
		l = list(A)
		mi = min(l)
		ma = max(l)
		sum = int(mi) + int(ma)
		return sum


class Solution:

	def findSum(self, A, N):
		if N == 0:
			return 0
		if N == 1:
			return 2 * A[0]
		A.sort()
		return A[0] + A[-1]


class Solution:

	def findSum(self, A, N):
		min_A = min(A)
		max_A = max(A)
		sum_mm = max_A + min_A
		return sum_mm


class Solution:

	def findSum(self, A, N):
		x = min(A)
		Y = max(A)
		return x + Y


class Solution:

	def findSum(self, A, N):
		N = len(A)
		if N % 2 == 0:
			mx = max(A[0], A[1])
			mn = min(A[0], A[1])
			i = 2
		else:
			mx = mn = A[0]
			i = 1
		while i < N - 1:
			if A[i] < A[i + 1]:
				mx = max(mx, A[i + 1])
				mn = min(mn, A[i])
			else:
				mx = max(mx, A[i])
				mn = min(mn, A[i + 1])
			i += 2
		return mx + mn


class Solution:

	def findSum(self, A, N):
		maxi = -99999
		mini = 99999
		for i in range(N):
			maxi = max(A[i], maxi)
			mini = min(A[i], mini)
		sum = maxi + mini
		return sum


class Solution:

	def findSum(self, A, N):
		maxi = float('-inf')
		mini = float('inf')
		for i in A:
			if i > maxi:
				maxi = i
			if i < mini:
				mini = i
		return maxi + mini


class Solution:

	def findSum(self, A, N):
		A.sort()
		mini = A[0]
		maxi = A[-1]
		return mini + maxi


class Solution:

	def findSum(self, A, N):
		minn = 1000000
		maxx = -1000000
		for i in A:
			if i > maxx:
				maxx = i
			if i < minn:
				minn = i
		return minn + maxx


class Solution:

	def findSum(self, A, N):
		l = max(A)
		b = min(A)
		s = l + b
		return s