Given a sorted array Arr of size N and a value X, find the number of array elements less than or equal to X and elements more than or equal to X. 
Example 1:
Input:
N = 7, X = 0
Arr[] = {1, 2, 8, 10, 11, 12, 19}
Output: 0 7
Explanation: There are no elements less or
equal to 0 and 7 elements greater or equal
to 0.
Example 2:
Input:
N = 7, X = 5
Arr[] = {1, 2, 8, 10, 11, 12, 19}
Output: 2 5
Explanation: There are 2 elements less or
equal to 5 and 5 elements greater or equal
to 5.
Your Task:
You don't need to read input or print anything. Your task is to complete the function getMoreAndLess() which takes the array of integers arr, n and x as parameters and returns an array of size 2. pair denoting the answer. The first value is number of elements less than or equal to x and the second value is number of elements more than or equal to x.
Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{5}
0 ≤ X ≤ 10^{6}
1 ≤ Arr[i] ≤ 10^{6}

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:

	def getMoreAndLess(self,arr, n, x):
		# code here

Solutions:
class Solution:

	def getMoreAndLess(self, arr, n, x):
		less_than = 0
		more_than = 0
		sol = []
		for i in arr:
			if i < x:
				less_than += 1
			elif i > x:
				more_than += 1
			else:
				less_than += 1
				more_than += 1
		sol.append(less_than)
		sol.append(more_than)
		return sol


class Solution:

	def getMoreAndLess(self, arr, n, x):
		less_than = 0
		greater_than = 0
		for i in range(n):
			if arr[i] <= x:
				less_than += 1
			if arr[i] >= x:
				greater_than += 1
		return [less_than, greater_than]


class Solution:

	def getMoreAndLess(self, arr, n, x):
		(smaller, larger) = (0, 0)
		for i in arr:
			if i <= x:
				smaller += 1
			if i >= x:
				larger += 1
		return (smaller, larger)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		less = 0
		greater = 0
		for i in range(n):
			if arr[i] <= x:
				less += 1
			if arr[i] >= x:
				greater += 1
		return (less, greater)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		m = len(arr)
		less_than_count = 0
		greater_than_count = 0
		for i in range(m):
			if arr[i] <= x:
				less_than_count += 1
			if arr[i] >= x:
				greater_than_count += 1
		return (less_than_count, greater_than_count)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		l = 0
		B = 0
		for i in range(n):
			if x <= arr[i]:
				l += 1
			if x >= arr[i]:
				B += 1
		return (B, l)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		c = 0
		d = 0
		for i in range(0, n):
			if arr[i] <= x:
				c = c + 1
			if arr[i] >= x:
				d = d + 1
		return (c, d)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		l_count = r_count = 0
		for i in arr:
			if i == x:
				(l_count, r_count) = (l_count + 1, r_count + 1)
			elif i < x:
				l_count += 1
			else:
				r_count += 1
		return (l_count, r_count)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		gt = 0
		lt = 0
		for i in arr:
			if x == i:
				lt += 1
				gt += 1
			elif x > i:
				lt += 1
			else:
				gt += 1
		return (lt, gt)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		result_arr = [0, 0]
		for num in arr:
			if num <= x:
				result_arr[0] += 1
			if num >= x:
				result_arr[1] += 1
		return result_arr


class Solution:

	def getMoreAndLess(self, arr, n, x):
		lesscount = 0
		morecount = 0
		for i in arr:
			if i < x or i == x:
				lesscount += 1
			if i > x or i == x:
				morecount += 1
		return (lesscount, morecount)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		small = 0
		greater = 0
		for i in arr:
			if i <= x:
				small += 1
			if i >= x:
				greater += 1
		return (small, greater)


class Solution:

	def getMoreAndLess(self, arr, n, X):
		s = 0
		l = 0
		for i in range(n):
			if arr[i] >= X:
				s += 1
			if arr[i] <= X:
				l += 1
		return (l, s)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		arr.sort()
		low = 0
		high = 0
		for i in range(n):
			if arr[i] <= x:
				low += 1
			if arr[i] >= x:
				high += 1
		return (low, high)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		(s, l) = (0, 0)
		for i in arr:
			if i <= x:
				s = s + 1
			if i >= x:
				l = l + 1
		return (s, l)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		lessThan = 0
		equalTo = 0
		for i in arr:
			if i < x:
				lessThan += 1
			elif i > x:
				equalTo += 1
			elif i == x:
				lessThan += 1
				equalTo += 1
		return (lessThan, equalTo)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		(lessarr, grtarr) = (0, 0)
		for i in arr:
			if i <= x:
				lessarr += 1
			if i >= x:
				grtarr += 1
		return (lessarr, grtarr)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		mini = 0
		maxi = 0
		for i in arr:
			if i <= x:
				mini += 1
			if i >= x:
				maxi += 1
		return (mini, maxi)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		cz = 0
		cn = 0
		for i in range(n):
			if arr[i] > x:
				cz += 1
			elif arr[i] < x:
				cn += 1
			else:
				cz += 1
				cn += 1
		return (cn, cz)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		A = []
		B = []
		for i in arr:
			if i < x:
				A.append(i)
			elif i == x:
				A.append(i)
				B.append(i)
			else:
				B.append(i)
		return (len(A), len(B))


class Solution:

	def getMoreAndLess(self, arr, n, x):
		less = 0
		more = 0
		array = []
		for num in arr:
			if num <= x:
				less += 1
			if num >= x:
				more += 1
		array.append(less)
		array.append(more)
		return array


class Solution:

	def getMoreAndLess(self, arr, n, x):
		cntmin = 0
		cntmax = 0
		for i in range(n):
			if arr[i] >= x:
				cntmax += 1
			if arr[i] <= x:
				cntmin += 1
		return (cntmin, cntmax)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		mi = 0
		ma = 0
		for i in arr:
			if i <= x:
				mi = mi + 1
			if i >= x:
				ma = ma + 1
		return (mi, ma)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		ans = [0, 0]
		for i in arr:
			if i <= x:
				ans[0] += 1
			if i >= x:
				ans[1] += 1
		return ans


class Solution:

	def getMoreAndLess(self, arr, n, x):
		c = 0
		c1 = 0
		for i in range(n):
			if arr[i] == x:
				c = c + 1
				c1 = c1 + 1
			elif arr[i] < x:
				c = c + 1
			elif arr[i] > x:
				c1 = c1 + 1
		ans = []
		ans.append(c)
		ans.append(c1)
		return ans


class Solution:

	def getMoreAndLess(self, arr, n, x):
		lst1 = []
		lst2 = []
		for i in range(0, n):
			if int(arr[i]) <= int(x):
				lst1.append(arr[i])
			if int(arr[i]) >= int(x):
				lst2.append(arr[i])
		return (len(lst1), len(lst2))


class Solution:

	def getMoreAndLess(self, arr, n, x):
		less = 0
		more = 0
		for i in arr:
			if i <= x:
				less = less + 1
			if i >= x:
				more = more + 1
		return (less, more)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		count_of_less = 0
		count_of_more = 0
		result = []
		for i in range(n):
			if arr[i] <= x:
				count_of_less = count_of_less + 1
			if arr[i] >= x:
				count_of_more = count_of_more + 1
		result.append(count_of_less)
		result.append(count_of_more)
		return result


class Solution:

	def getMoreAndLess(self, arr, n, x):
		less_ = 0
		max_ = 0
		for val in arr:
			if val <= x:
				less_ += 1
			if val >= x:
				max_ += 1
		return (less_, max_)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		c1 = c2 = 0
		for i in arr:
			if x >= i:
				c1 += 1
		for i in arr:
			if x <= i:
				c2 += 1
		else:
			return [c1, c2]


class Solution:

	def getMoreAndLess(self, arr, n, x):
		c = []
		less = 0
		more = 0
		for i in arr:
			if i < x:
				less += 1
			elif i > x:
				more += 1
			else:
				less += 1
				more += 1
		c.append(less)
		c.append(more)
		return c


class Solution:

	def getMoreAndLess(self, arr, n, x):
		l = []
		l1 = []
		l2 = []
		for i in arr:
			if i <= x:
				l1.append(i)
		for i in arr:
			if i >= x:
				l2.append(i)
		l.append(len(l1))
		l.append(len(l2))
		return l


class Solution:

	def getMoreAndLess(self, arr, n, x):
		count_less = 0
		count_more = 0
		for i in arr:
			if i < x:
				count_less += 1
			elif i > x:
				count_more += 1
			else:
				count_less += 1
				count_more += 1
		return (count_less, count_more)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		count = 0
		count_1 = 0
		for i in arr:
			if x <= i:
				count += 1
			if x >= i:
				count_1 += 1
		return (count_1, count)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		l = 0
		g = 0
		for number in arr:
			if number <= x:
				l += 1
			if number >= x:
				g += 1
		return (l, g)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		less = 0
		great = 0
		for i in arr:
			if i <= x:
				less = less + 1
			if i >= x:
				great = great + 1
		res = [less, great]
		return res


class Solution:

	def getMoreAndLess(self, arr, n, x):
		temp = 0
		ans = 0
		for i in range(0, len(arr)):
			if arr[i] <= x:
				temp += 1
			if arr[i] >= x:
				ans += 1
		return (temp, ans)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		countless = 0
		countmore = 0
		for i in arr:
			if i <= x:
				countless += 1
			if i >= x:
				countmore += 1
		return (countless, countmore)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		(a, b) = ([int(i <= x) for i in arr], [int(i >= x) for i in arr])
		return (sum(a), sum(b))


class Solution:

	def getMoreAndLess(self, arr, n, x):
		a = 0
		y = 0
		for i in arr:
			if i <= x:
				a += 1
			if i >= x:
				y += 1
		return (a, y)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		l = [i for i in arr if i >= x]
		s = [j for j in arr if j <= x]
		return [len(s), len(l)]


class Solution:

	def getMoreAndLess(self, arr, n, x):
		less = 0
		more = 0
		count = 0
		for i in range(n):
			if arr[i] < x:
				less = i + 1
			elif arr[i] > x:
				more = n - i
				break
			else:
				count += 1
		less += count
		more += count
		if arr[-1] < x:
			less = n
			more = 0
		if arr[0] > x:
			more = n
			less = 0
		return [less, more]


class Solution:

	def getMoreAndLess(self, arr, n, x):
		lis = [0, 0]
		i = 0
		j = 0
		for k in range(len(arr)):
			if arr[k] <= x:
				i += 1
			if arr[k] >= x:
				j += 1
		return (i, j)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		great = []
		less = []
		for i in arr:
			if i >= x:
				great.append(i)
			if i <= x:
				less.append(i)
		return [len(less), len(great)]


class Solution:

	def getMoreAndLess(self, arr, n, x):
		min = 0
		max = 0
		for i in arr:
			if i <= x:
				min += 1
			if i >= x:
				max += 1
		return (min, max)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		is_less = 0
		is_greater = 0
		for i in arr:
			if i < x:
				is_less += 1
			elif i > x:
				is_greater += 1
			elif i == x:
				is_less += 1
				is_greater += 1
		return (is_less, is_greater)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		minimum = 0
		maximum = 0
		for i in range(n):
			if arr[i] >= x:
				maximum += 1
			if arr[i] <= x:
				minimum += 1
		return [minimum, maximum]


class Solution:

	def getMoreAndLess(self, arr, n, x):
		les = 0
		gre = 0
		for i in arr:
			if i <= x:
				les += 1
		for i in arr:
			if i >= x:
				gre += 1
		return (les, gre)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		small = 0
		large = n
		if arr[0] != arr[n - 1]:
			for ele in arr:
				if ele <= x:
					if ele == x:
						small += 1
					else:
						small += 1
						large -= 1
			return (small, large)
		return (n, n)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		a = 0
		b = 0
		for i in arr:
			if i < x:
				a = a + 1
			elif i == x:
				a = a + 1
				b = b + 1
			else:
				b = b + 1
		return [a, b]


class Solution:

	def getMoreAndLess(self, arr, n, x):
		counta = 0
		countb = 0
		for i in range(0, len(arr)):
			if arr[i] <= x:
				counta = counta + 1
			if arr[i] >= x:
				countb = countb + 1
		return (counta, countb)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		l1 = 0
		m1 = 0
		for i in arr:
			if i >= x:
				l1 += 1
			if i <= x:
				m1 += 1
		return (m1, l1)


class Solution:

	def getMoreAndLess(self, arr, n, x):
		a1 = 0
		a2 = 0
		ans = []
		for y in arr:
			if y <= x:
				a1 = a1 + 1
			if y >= x:
				a2 = a2 + 1
		ans.append(a1)
		ans.append(a2)
		return ans


class Solution:

	def getMoreAndLess(self, arr, n, x):
		output_array = []
		less_then = 0
		greater_then = 0
		for num in arr:
			if num >= x:
				greater_then += 1
			if num <= x:
				less_then += 1
		output_array.append(less_then)
		output_array.append(greater_then)
		return output_array


class Solution:

	def getMoreAndLess(self, arr, n, x):
		ans = []
		l_count = 0
		m_count = 0
		for i in arr:
			if i <= x:
				l_count += 1
			if i >= x:
				m_count += 1
		ans.append(l_count)
		ans.append(m_count)
		return ans


class Solution:

	def getMoreAndLess(self, arr, n, x):
		i = 0
		num_less = 0
		num_greater = 0
		ans = []
		while i < n:
			if arr[i] <= x:
				num_less += 1
			if arr[i] >= x:
				num_greater += 1
			i += 1
		ans.append(num_less)
		ans.append(num_greater)
		return ans


class Solution:

	def getMoreAndLess(self, arr, n, x):
		largest_ele = 0
		smallest_ele = 0
		for i in range(n):
			if arr[i] <= x:
				smallest_ele += 1
			if arr[i] >= x:
				largest_ele += 1
		return (smallest_ele, largest_ele)