One day Jay, on getting his first salary, decides to distribute apples among the poverty-stricken persons. He gave each person 1kg of apples. People are coming in a queue and he makes sure that he gives every person 1 kg of apples only once. Every person is identified by a specific integer.
Given the length of the queue N followed by an array of N integers, denoting the persons in that queue, find the minimum kilograms of apples Jay will have to distribute.
Example 1:
Ã¢â¬â¹Input : arr[ ] = {1, 1, 1, 1, 1}
Output : 1
Explanation:
For test case 1, the same person (identified 
by the integer '1' comes again and again in 
the queue, but Jay will not give him apples 
again and again. He gave him apples only 
once so minimum kg's of apples here 
required-1kg).
Ã¢â¬â¹Example 2:
Input : arr[ ] = {1, 2, 3, 1, 2} 
Output :  3 
 
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 minimum_apple() that takes an array (arr), sizeOfArray (n) and return the minimum kilograms of apples Jay will have to distribute. The driver code takes care of the printing.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
 
Constraints:
1 ≤ N ≤ 10^{5}
1 ≤ A_{i} ≤ 10^{5}

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

Starter code:
#User function Template for python3





def minimum_apple (arr, n) : 

    #Complete the function



Solutions:
def minimum_apple(arr, n):
	arr = list(set(arr))
	return len(arr)


def minimum_apple(arr, n):
	x = set(arr)
	y = len(x)
	return y


def minimum_apple(arr, n):
	s = set(arr)
	return s.__len__()


def minimum_apple(arr, n):
	a = set(arr)
	return len(a)


def minimum_apple(arr, n):
	alist = dict()
	for i in range(n):
		alist[arr[i]] = alist.get(arr[i], 0) + 1
	x = len(alist.keys())
	return x


def minimum_apple(arr, n):
	k = set(arr)
	return len(k)


def minimum_apple(arr, n):
	a = []
	for i in range(n):
		a.append(arr[i])
	a = list(set(a))
	return len(a)


def minimum_apple(arr, n):
	res = set()
	for i in arr:
		res.add(i)
	return len(res)


def minimum_apple(arr, n):
	set_arr = set(arr)
	return len(set_arr)


def minimum_apple(arr, n):
	s = set(arr)
	return len(s)


from collections import Counter

def minimum_apple(arr, n):
	d = Counter(arr)
	count = 0
	for (key, value) in d.items():
		count = count + 1
	return count


def minimum_apple(arr, n):
	set_a = set(arr)
	length = len(set_a)
	return length


def minimum_apple(arr, n):
	a = set(arr)
	b = list(a)
	return len(b)


def minimum_apple(arr, n):
	freq = {}
	for i in range(0, n):
		if arr[i] in freq:
			i += 1
		else:
			freq[arr[i]] = 1
	res = []
	for (k, v) in freq.items():
		if v == 1:
			res.append(k)
	return len(res)


def minimum_apple(arr, n):
	if len(arr) == n:
		arr_set = set(arr)
		output = len(arr_set)
		return output


def minimum_apple(arr, n):
	a1 = set(arr)
	return len(a1)


def minimum_apple(arr, n):
	d = {}
	for i in arr:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	return len(d)


def minimum_apple(arr, n):
	st = set()
	for element in arr:
		if element not in st:
			st.add(element)
	return len(st)


def minimum_apple(arr, n):
	st = set(arr)
	return len(st)


def minimum_apple(arr, n):
	b = set(arr)
	return len(b)


def minimum_apple(arr, n):
	arr.sort()
	count = 1
	for i in range(len(arr) - 1):
		if arr[i] != arr[i + 1]:
			count += 1
	return count


def minimum_apple(arr, n):
	c = len(set(arr))
	return c


def minimum_apple(arr, n):
	result_set = set(arr)
	return len(result_set)


def minimum_apple(arr, n):
	ko = 0
	mp = {}
	for i in arr:
		if i not in mp:
			mp[i] = 1
			ko += 1
	return ko


def minimum_apple(arr, n):
	count = 0
	dic = {}
	for i in arr:
		if i not in dic:
			dic[i] = 1
	k = len(dic)
	return k


def minimum_apple(arr: list, n: int) -> int:
	seen = set()
	count = 0
	for i in range(n):
		if arr[i] not in seen:
			count += 1
			seen.add(arr[i])
	return count


def minimum_apple(arr, n):
	dic = dict()
	c = 0
	for i in arr:
		if i not in dic:
			dic[i] = 1
			c += 1
	return c


def minimum_apple(arr, n):
	mp = {}
	for i in arr:
		if i in mp:
			mp[i] += 1
		else:
			mp[i] = 1
	l = []
	for i in mp.keys():
		l.append(i)
	return len(l)


def minimum_apple(arr, n):
	dict1 = {}
	for i in range(n):
		dict1[arr[i]] = dict1.get(arr[i], 0) + 1
	return len(dict1)


def minimum_apple(arr, n):
	mp = {}
	for i in arr:
		mp[i] = mp.get(i, 1)
	return len(mp)


def minimum_apple(arr, n):
	res = 0
	d = {}
	for i in arr:
		if i not in d:
			d[i] = 0
		d[i] += 1
	for i in arr:
		if i in d:
			res += 1
			del d[i]
	return res


def minimum_apple(arr, n):
	l = set(arr)
	return len(l)


def minimum_apple(arr, n):
	arr1 = set(arr)
	return len(arr1)


def minimum_apple(arr, n):
	s = set()
	for x in arr:
		s.add(x)
	return len(s)


def minimum_apple(arr, n):
	S = set(arr)
	return len(S)


def minimum_apple(arr, n):
	s = list(set(arr))
	ans = len(s)
	return ans


def minimum_apple(arr, n):
	ans = set(arr)
	return len(ans)


def minimum_apple(arr, n):
	frq = dict()
	sum = 0
	for i in range(0, n):
		if arr[i] not in frq.keys():
			frq[arr[i]] = +1
			sum = sum + 1
	return sum


def minimum_apple(arr, n):
	dic = {}
	for i in arr:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	c = 0
	for j in dic:
		c += 1
	return c