Given an array of N integers and Q queries of indices, print the number of next greater elements(NGEs) to the right of the given index element. 
Example:
Input:  arr     = [3, 4, 2, 7, 5, 8, 10, 6]
        queries = 2
        indices = [0, 5]
Output:  6, 1
Explanation:  
The next greater elements to the right of 3(index 0)
are 4,7,5,8,10,6.  
The next greater elements to the right of 8(index 5)
is only 10.
Your Task:
You don't need to read or print anything. Your task is to complete the function count_NGEs() which takes N, arr, queries and indices as the input parameter and returns a list NGEs[] where NGEs[i] stores the count of elements strictly greater than the current element (arr[indices[i]]) to the right of indices[i].
Expected Time Complexity: O(N * queries).
Expected Auxiliary Space: O(queries).
Constraints:
1 <= N <= 10^{4}
1 <= arr[i] <= 10^{5}
1 <= queries <= 100
0 <= indices[i] <= N - 1

Difficulty: EASY
Expected Time Complexity: O(N * queries).
Expected Auxiliary Space: O(queries).

Starter code:
#User function Template for python3



class Solution:

    def count_NGEs(self, N, arr, queries, indices):

        # Code here

Solutions:
class Solution:

	def count_NGEs(self, N, arr, queries, indices):

		def nge(ind, arr, N, key):
			c = 0
			for i in range(ind, N):
				if arr[i] > key:
					c += 1
			return c
		st = []
		for i in indices:
			st.append(nge(i, arr, N, arr[i]))
		return st


class Solution:

	def count_NGEs(self, N, arr, queries, indices):

		def nge(ind, arr, N, key):
			cnt = 0
			for i in range(ind, N):
				if arr[i] > key:
					cnt += 1
			return cnt
		ans = []
		for i in indices:
			ans.append(nge(i, arr, N, arr[i]))
		return ans


class Solution(object):

	def count_NGEs(self, N, nums, queries, indices):

		def findNextGreaterNums(index):
			(curr, count) = (nums[index], 0)
			for i in range(index + 1, N):
				if nums[i] > curr:
					count += 1
			return count
		result = []
		for index in indices:
			result.append(findNextGreaterNums(index))
		return result


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		l = []
		n = len(arr)
		for i in range(queries - 1, -1, -1):
			c = 0
			for j in range(n - 1, indices[i], -1):
				if arr[indices[i]] < arr[j]:
					c = c + 1
			l.append(c)
		l.reverse()
		return l


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		res = [0 for _ in range(queries)]
		for i in range(queries):
			cnt = 0
			k = indices[i]
			for j in range(k + 1, N):
				if arr[k] < arr[j]:
					cnt += 1
			res[i] = cnt
		return res


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		list = []
		for x in range(len(indices)):
			max = arr[indices[x]]
			sum = 0
			for y in range(indices[x] + 1, N):
				if max < arr[y]:
					sum += 1
			list.append(sum)
		return list


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		great_arr = []
		for query in indices:
			great = 0
			for i in range(query + 1, N):
				if arr[i] > arr[query]:
					great += 1
			great_arr.append(great)
		return great_arr


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		res = []
		for i in indices:
			x = arr[i]
			count = 0
			for j in range(i + 1, N):
				if x < arr[j]:
					count += 1
			res.append(count)
		return res


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		i = 0
		while i < queries:
			j = indices[i]
			temp = arr[indices[i]]
			count = 0
			while j < N:
				if arr[j] > temp:
					count += 1
				j += 1
			i += 1
			ans.append(count)
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		NGEs = []
		for index in indices:
			count = 0
			num = arr[index]
			for i in range(index + 1, len(arr)):
				if arr[i] > num:
					count += 1
			NGEs.append(count)
		return NGEs


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		for j in range(queries):
			t = indices[j]
			k = arr[t]
			c = 0
			for i in range(t + 1, N):
				if arr[i] > k:
					c += 1
			indices[j] = c
		return indices


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		a = []
		for i in range(queries):
			t = arr[indices[i]]
			count = 0
			for j in range(indices[i] + 1, N):
				if arr[j] > t:
					count += 1
			a.append(count)
		return a


from collections import deque

class Solution:

	def __init__(self):
		self.count = 0

	def count_NGEs(self, N, arr, queries, indices):
		answer = []
		for i in range(queries):
			count = 0
			for j in range(indices[i] + 1, N):
				if arr[j] > arr[indices[i]]:
					count += 1
			answer.append(count)
		return answer


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		result = []
		for i in range(queries):
			count = 0
			for j in range(indices[i] + 1, len(arr)):
				if arr[j] > arr[indices[i]]:
					count += 1
			result.append(count)
		return result


class Solution:

	def count_NGEs(self, n, arr, queries, indices):
		result = []
		for index in indices:
			count = 0
			for i in range(index + 1, n):
				if arr[i] > arr[index]:
					count += 1
			result.append(count)
		return result


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		nxges = []
		for index in indices:
			nxg = 0
			for i in range(index + 1, N):
				if arr[index] < arr[i]:
					nxg += 1
			nxges.append(nxg)
		return nxges


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		for q in range(queries):
			ind = indices[q]
			count = 0
			for i in range(ind, N):
				if arr[ind] < arr[i]:
					count += 1
			ans.append(count)
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		for indx in indices:
			cnt = 0
			for i in range(indx, N):
				cnt += arr[i] > arr[indx]
			ans.append(cnt)
		return ans


class Solution:

	def count_NGEs(self, n, arr, queries, indices):
		res = []
		for ind in indices:
			curr = arr[ind]
			c = 0
			for i in range(ind + 1, n):
				if curr < arr[i]:
					c += 1
			res.append(c)
		return res


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = [0 for j in range(queries)]
		indx = 0
		while queries != 0:
			idx = indices.pop(0)
			cnt = 0
			for j in range(idx + 1, N):
				if arr[j] > arr[idx]:
					cnt += 1
			ans[indx] = cnt
			indx += 1
			queries -= 1
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		for i in range(queries):
			index = indices[i]
			count = 0
			for j in range(index + 1, N):
				if arr[j] > arr[index]:
					count += 1
			ans.append(count)
		return ans


class Solution:

	def count_NGEs(self, n, arr, queries, indices):
		ans = []
		for q in indices:
			el = arr[q]
			cnt = 0
			for i in range(q, n):
				if arr[i] > el:
					cnt += 1
			ans.append(cnt)
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		for i in indices:
			num = arr[i]
			count = 0
			for x in arr[i:]:
				if x > num:
					count += 1
			ans.append(count)
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		res = []
		for i in range(queries):
			k = indices[i]
			count = 0
			for i in range(k + 1, len(arr)):
				if arr[i] > arr[k]:
					count += 1
			res.append(count)
		return res


class Solution:

	def count_NGEs(self, N, arr, M, indices):
		count = [0 for _ in range(M)]
		for i in range(M):
			for j in range(indices[i], N):
				if arr[j] > arr[indices[i]]:
					count[i] += 1
		return count


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		res = [0 for _ in range(queries)]
		for i in range(queries):
			idx = indices[i]
			count = 0
			for j in range(idx, N):
				if arr[j] > arr[idx]:
					count += 1
			res[i] = count
		return res


class Solution:

	def count_NGEs(self, n, arr, queries, indices):
		res = []
		for i in range(len(indices)):
			index = indices[i]
			count = 0
			for j in range(index, len(arr)):
				if arr[index] < arr[j]:
					count += 1
			res.append(count)
		return res


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		list1 = []
		for index in indices:
			count = 0
			val = arr[index]
			for i in range(index + 1, N):
				if arr[i] > val:
					count += 1
				else:
					continue
			list1.append(count)
		return list1


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ls = []
		n = len(arr)
		for i in indices:
			cnt = 0
			for j in range(i + 1, n):
				if arr[j] > arr[i]:
					cnt += 1
			ls.append(cnt)
		return ls


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		count = []
		for i in indices:
			c = 0
			for e in range(i, N):
				if arr[i] < arr[e]:
					c = c + 1
			count.append(c)
		return count


class Solution:

	def count_NGEs(self, N, arr, q, ind):
		k = []
		for i in range(q):
			count = 0
			if ind[i] != N - 1:
				for j in range(ind[i] + 1, N):
					if arr[j] > arr[ind[i]]:
						count += 1
			k.append(count)
		return k


class Solution:

	def count_NGEs(self, n, arr, q, ind):
		ans = []
		for i in range(q):
			count = 0
			for j in range(ind[i] + 1, n):
				if arr[j] > arr[ind[i]]:
					count += 1
			ans.append(count)
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		for (z, point) in enumerate(indices):
			temp = 0
			for i in range(point + 1, N):
				if arr[i] > arr[point]:
					temp += 1
			ans.append(temp)
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		res = []
		for ind in indices:
			count = 0
			cur = arr[ind]
			for i in range(ind + 1, N):
				if arr[i] > cur:
					count += 1
			res.append(count)
		return res


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		for ind in indices:
			cnt = 0
			for i in range(N):
				if ind < i and arr[i] > arr[ind]:
					cnt += 1
			ans += [cnt]
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		count_Arr = [-1] * queries
		for i in range(0, queries):
			count = 0
			for j in range(indices[i] + 1, len(arr)):
				if arr[indices[i]] < arr[j]:
					count += 1
				else:
					j += 1
			count_Arr[i] = count
		return count_Arr


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		l = []
		c = 0
		for i in indices:
			ind = i
			for j in arr[ind:]:
				if j > arr[ind]:
					c += 1
			l.append(c)
			c = 0
		return l


def count(arr, B):
	ct = 0
	n = len(arr)
	for i in range(B, n):
		if arr[i] > arr[B]:
			ct += 1
	return ct

class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		n = len(indices)
		ans = [0] * n
		for i in range(n):
			ans[i] = count(arr, indices[i])
		return ans


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		res = []
		stack = []
		for i in range(queries):
			ind = indices[i]
			count = 0
			for j in range(ind + 1, len(arr)):
				if arr[j] > arr[ind]:
					count += 1
			res.append(count)
		return res


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		count = 0
		nge = []
		for g in range(queries):
			if N == 1:
				return [0] * queries
			for h in range(N - 1, indices[g], -1):
				if arr[h] > arr[indices[g]]:
					count += 1
			nge.append(count)
			count = 0
		return nge


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		ans = []
		for i in range(len(indices)):
			if indices[i] == len(arr) - 1:
				ans.append(0)
			else:
				ans.append(self.count_nge(indices[i], arr))
		return ans

	def count_nge(self, index, arr):
		count = 0
		for i in range(index + 1, len(arr)):
			if arr[i] > arr[index]:
				count += 1
		return count


class Solution:

	def count_NGEs(self, N, arr, queries, indices):
		res = []
		for i in indices:
			ans = []
			for j in range(i, N):
				if arr[j] > arr[i]:
					ans.append(arr[j])
			res.append(len(ans))
		return res


class Solution:

	def count_NGEs(self, n, a, q, indices):
		ngr = []
		for idx in indices:
			cnt = 0
			for i in range(idx + 1, n):
				if a[i] > a[idx]:
					cnt += 1
			ngr.append(cnt)
		return ngr