Given three distinct numbers A, B and C. Find the number with value in middle (Try to do it with minimum comparisons).
Example 1:
Input:
A = 978, B = 518, C = 300
Output:
518
Explanation:
Since 518>300 and 518<978, so 
518 is the middle element.
Example 2:
Input:
A = 162, B = 934, C = 200
Output:
200
Exaplanation:
Since 200>162 && 200<934,
So, 200 is the middle element.
Your Task:
You don't need to read input or print anything.Your task is to complete the function middle() which takes three integers A,B and C as input parameters and returns the number which has middle value.
Expected Time Complexity:O(1)
Expected Auxillary Space:O(1)
Constraints:
1<=A,B,C<=10^{9}
A,B,C are distinct.

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def middle(self,A,B,C):
        #code here


Solutions:
class Solution:

	def middle(self, A, B, C):
		if A > B > C or C > B > A:
			return B
		elif A > C > B or B > C > A:
			return C
		else:
			return A


class Solution:

	def middle(self, A, B, C):
		a = max(A, B, C)
		b = min(A, B, C)
		return A + B + C - a - b


class Solution:

	def middle(self, A, B, C):
		l = [A, B, C]
		a = max(l)
		b = min(l)
		for i in l:
			if (i != a) & (i != b):
				return i


class Solution:

	def middle(self, A, B, C):
		l = [A, B, C]
		l.sort()
		return l[1]


class Solution:

	def middle(self, A, B, C):
		if B > A and A > C or (C > A and A > B):
			return A
		if A > B and B > C or (C > B and B > A):
			return B
		if A > C and C > B or (B > C and C > A):
			return C


class Solution:

	def middle(self, A, B, C):
		if A > B and A > C:
			if B > C:
				return B
			else:
				return C
		if B > A and B > C:
			if A > C:
				return A
			else:
				return C
		if C > A and C > B:
			if A > B:
				return A
			else:
				return B
		return 0


class Solution:

	def middle(self, A, B, C):
		if A > B > C:
			return B
		if C > B > A:
			return B
		if A > C > B:
			return C
		if B > C > A:
			return C
		else:
			return A


class Solution:

	def middle(self, A, B, C):
		x = [A, B, C]
		x.sort()
		return x[1]


class Solution:

	def middle(self, A, B, C):
		max_num = max(A, B, C)
		min_num = min(A, B, C)
		middle_num = A + B + C - max_num - min_num
		return middle_num


class Solution:

	def middle(self, A, B, C):
		return A + B + C - max(A, B, C) - min(A, B, C)


class Solution:

	def middle(self, A, B, C):
		arr = []
		arr.append(A)
		arr.append(B)
		arr.append(C)
		arr.sort()
		return arr[1]


class Solution:

	def middle(self, A, B, C):
		return sorted([A, B, C])[1]


class Solution:

	def middle(self, A, B, C):
		l1 = []
		l1.append(A)
		l1.append(B)
		l1.append(C)
		l1.remove(min(l1))
		l1.remove(max(l1))
		return l1[0]


class Solution:

	def middle(self, A, B, C):
		import statistics
		median = statistics.median([A, B, C])
		return median


class Solution:

	def middle(self, a, b, c):
		x = sorted([a, b, c])
		return x[1]


class Solution:

	def middle(self, A, B, C):
		lst = [A, B, C]
		lst.sort()
		return lst[1]


class Solution:

	def middle(self, a, b, c):
		if a < b & b < c:
			return b
		elif a < c & c < b:
			return c
		elif b < a & a < c:
			return a
		elif b < c & c < a:
			return c
		elif c < a & a < b:
			return a
		elif c < b & b < a:
			return b


class Solution:

	def middle(self, A, B, C):
		l = []
		l.append(A)
		l.append(B)
		l.append(C)
		s = sorted(l)[1]
		return s


class Solution:

	def middle(self, A, B, C):
		a = [A, B, C]
		a.sort()
		return a[1]


class Solution:

	def middle(self, A, B, C):
		l = []
		l1 = []
		l1.append(A)
		l1.append(B)
		l1.append(C)
		m = max(A, B, C)
		mi = min(A, B, C)
		l.append(m)
		l.append(mi)
		for i in l1:
			if i in l:
				pass
			else:
				return i


class Solution:

	def middle(self, A, B, C):
		a = [A, B, C]
		a.sort()
		return a[-2]


class Solution:

	def middle(self, A, B, C):
		list1 = [A, B, C]
		list1.sort()
		return list1[1]


class Solution:

	def middle(self, A, B, C):
		t = max(A, B, C)
		u = min(A, B, C)
		if A != t and A != u:
			return A
		elif B != t and B != u:
			return B
		else:
			return C


class Solution:

	def middle(self, A, B, C):
		d = [A, B, C]
		m = sorted(d)
		return m[1]


class Solution:

	def middle(self, A, B, C):
		if A > B:
			if B > C:
				return B
		elif A > C:
			return A
		if A > C:
			if C > B:
				return C
		elif A > B:
			return A
		if B > C:
			if C > A:
				return C
		elif B > A:
			return B


class Solution:

	def middle(self, A, B, C):
		l = [A, B, C]
		l.sort()
		return l[-2]


class Solution:

	def middle(self, A, B, C):
		s = A + B + C
		minm = A
		maxi = A
		if B < A:
			minm = B
		else:
			maxi = B
		if minm > C:
			minm = C
		if maxi < C:
			maxi = C
		return s - (maxi + minm)


class Solution:

	def middle(self, A, B, C):
		ma = max(A, max(B, C))
		mi = min(A, min(B, C))
		tot = A + B + C
		res = tot - (ma + mi)
		return res