Given an array consisting of only prime numbers, remove all duplicate numbers from it. 
Example 1:
Input:
N = 6
A[] = {2,2,3,3,7,5}
Output: 2 3 7 5
Explanation: After removing the duplicate
2 and 3 we get 2 3 7 5.
Your Task:
Complete the function removeDuplicate() that takes the array of integers and N as input parameters and returns the modified array which has no duplicates. Retain only the first occurrence of the duplicate element. The elements in the returning array should be in the same order as they appear in the original array.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
Constraints:
1<=N=10^{6}
2<=A[i]<100

Source: geeksforgeeks | Difficulty: EASY
Tags: Number theory

Data structures

String algorithms

Starter code: class Solution:
    def removeDuplicates(self, arr):
        # code here 
    

Solutions:
class Solution:

	def removeDuplicates(self, arr):
		ans = []
		s = set()
		for ele in arr:
			if ele not in s:
				ans.append(ele)
				s.add(ele)
		return ans


class Solution:

	def removeDuplicates(self, arr):
		s = set()
		result = []
		for num in arr:
			if num not in s:
				result.append(num)
				s.add(num)
		return result


class Solution:

	def removeDuplicates(self, arr):
		dp = [0] * 100
		tmp = list()
		for prime in arr:
			if dp[prime] == 0:
				tmp.append(prime)
				dp[prime] = 1
		result = []
		for prime in tmp:
			result.append(prime)
		return result


class Solution:

	def removeDuplicates(self, arr):
		uniq = []
		d = {}
		for elem in arr:
			if not d.get(elem, 0):
				uniq.append(elem)
				d[elem] = 1
		return uniq


class Solution:

	def removeDuplicates(self, arr):
		freq_map = {}
		ans = []
		for i in range(len(arr)):
			if arr[i] not in freq_map:
				freq_map[arr[i]] = 1
				ans.append(arr[i])
		return ans


class Solution:

	def removeDuplicates(self, arr):
		l = []
		s = set()
		for i in arr:
			if i not in s:
				l.append(i)
				s.add(i)
		return l


class Solution:

	def removeDuplicates(self, arr):
		pdt = 1
		lst2 = []
		for num in arr:
			rem = pdt % num
			if rem != 0:
				lst2.append(num)
				pdt = pdt * num
		return lst2


class Solution:

	def removeDuplicates(self, arr):
		s = []
		seen = {}
		for i in arr:
			if i not in seen:
				s.append(i)
				seen[i] = 1
		return s


class Solution:

	def removeDuplicates(self, arr):
		unique = set()
		list1 = []
		for i in arr:
			if i not in unique:
				unique.add(i)
				list1.append(i)
		return list1


class Solution:

	def removeDuplicates(self, arr):
		l = []
		d = {}
		for i in arr:
			if i not in d:
				l.append(i)
				d[i] = 1
		return l


class Solution:

	def removeDuplicates(self, arr):
		b = []
		a = set()
		for i in arr:
			if i not in a:
				b.append(i)
				a.add(i)
		return b


from collections import OrderedDict

class Solution:

	def removeDuplicates(self, arr):
		a = []
		di = OrderedDict()
		for j in arr:
			di[j] = 0
		a.extend(di.keys())
		return a


from collections import OrderedDict

class Solution:

	def removeDuplicates(self, arr):
		dic = OrderedDict()
		for e in arr:
			dic[e] = 1
		arr2 = []
		for (i, v) in dic.items():
			arr2.append(i)
		return arr2


class Solution:

	def removeDuplicates(self, arr):
		res = []
		dict = {}
		for item in arr:
			if item not in dict:
				res.append(item)
				dict[item] = 1
		return res


from collections import OrderedDict

class Solution:

	def removeDuplicates(self, arr):
		a = list(OrderedDict.fromkeys(arr))
		return a


class Solution:

	def removeDuplicates(self, arr):
		store = set()
		duplicate = []
		for i in arr:
			if i not in store:
				store.add(i)
				duplicate += [i]
		return duplicate


class Solution:

	def removeDuplicates(self, arr):
		seen = set()
		return [x for x in arr if not (x in seen or seen.add(x))]


class Solution:

	def removeDuplicates(self, arr):
		res = []
		dic = {}
		for i in arr:
			if i not in dic:
				res.append(i)
				dic[i] = 1
		return res


class Solution:

	def removeDuplicates(self, arr):
		st = set()
		lis = []
		for i in arr:
			if i not in st:
				lis.append(i)
				st.add(i)
		return lis


class Solution:

	def removeDuplicates(self, arr):
		if len(arr) == len(set(arr)):
			return arr
		else:
			ans = []
			d = {}
			for i in arr:
				if i not in d:
					d[i] = 1
					ans.append(i)
		return ans


class Solution:

	def removeDuplicates(self, arr):
		freq = {}
		ans = []
		for i in arr:
			if i not in freq:
				ans.append(i)
			freq[i] = True
		return ans


class Solution:

	def removeDuplicates(self, arr):
		a = []
		s = {}
		for i in arr:
			if i not in s:
				a.append(i)
				s[i] = i
		return a


class Solution:

	def removeDuplicates(self, arr):
		res = set()
		ans = []
		for i in arr:
			if i not in res:
				res.add(i)
				ans.append(i)
		return ans


class Solution:

	def removeDuplicates(self, arr):
		h = {}
		a = []
		for i in range(len(arr)):
			if arr[i] not in h:
				a.append(arr[i])
				h[arr[i]] = 1
		return a


class Solution:

	def removeDuplicates(self, arr):
		abc = [0] * 100
		out = []
		for i in arr:
			if abc[i] == 0:
				out.append(i)
				abc[i] = 1
		return out


class Solution:

	def removeDuplicates(self, arr):
		l = []
		d = [False] * 100
		i = 0
		while i < len(arr):
			if not d[arr[i]]:
				l.append(arr[i])
				d[arr[i]] = True
			i += 1
		return l


class Solution:

	def removeDuplicates(self, arr):
		d = {}
		x = []
		for i in arr:
			if i in d:
				d[i] = 1
			else:
				x.append(i)
				d[i] = 1
		return x


class Solution:

	def removeDuplicates(self, arr):
		a = [0] * 100
		X = len(arr)
		i = 0
		nn = []
		while i < X:
			if a[arr[i]] == 0:
				a[arr[i]] = 1
				nn.append(arr[i])
			i += 1
		return nn


class Solution:

	def removeDuplicates(self, a):
		p = [0] * 100
		k = []
		for i in a:
			if p[i] == 0:
				p[i] = 1
				k.append(i)
		return k


class Solution:

	def removeDuplicates(self, arr):
		list1 = list()
		seta = set()
		for i in arr:
			if i not in seta:
				list1.append(i)
				seta.add(i)
		return list1


class Solution:

	def removeDuplicates(self, arr):
		prod = arr[0]
		res_ind = 1
		for i in range(1, len(arr)):
			if prod % arr[i] != 0:
				arr[res_ind] = arr[i]
				res_ind += 1
				prod *= arr[i]
		del arr[res_ind:]
		return arr


class Solution:

	def removeDuplicates(self, arr):
		prev = 0
		prod = 1
		n = len(arr)
		for i in range(0, n):
			if prod % arr[i] != 0:
				arr[prev] = arr[i]
				prev += 1
				prod *= arr[i]
		arr = arr[0:prev]
		return arr


class Solution:

	def removeDuplicates(self, arr):
		l = []
		p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
		b = [True for i in range(101)]
		for i in p:
			b[i] = False
		for i in arr:
			if b[i] == False:
				l.append(i)
				b[i] = True
		return l


class Solution:

	def removeDuplicates(self, arr):
		(res, temp) = ([], set())
		for i in arr:
			if not res or i not in temp:
				res.append(i)
				temp.add(i)
		return res


class Solution:

	def removeDuplicates(self, arr):
		sample = dict()
		output = []
		for x in arr:
			if x in sample:
				sample[0] = 0
			else:
				output.append(x)
				sample[x] = 1
		return output


class Solution:

	def removeDuplicates(self, arr: list):
		count = [0] * 100
		result = []
		for i in arr:
			if count[i] == 0:
				count[i] = 1
				result.append(i)
		return result


from collections import OrderedDict

class Solution:

	def removeDuplicates(self, arr):
		od = OrderedDict()
		for i in arr:
			if i not in od:
				od[i] = 1
		return list(od.keys())


class Solution:

	def removeDuplicates(self, arr):
		x = set()
		z = []
		for i in arr:
			if i not in x:
				z.append(i)
				x.add(i)
		return z


from collections import Counter

class Solution:

	def removeDuplicates(self, arr):
		s = []
		dict = {}
		for i in arr:
			if i not in dict:
				s.append(i)
				dict[i] = 1
		return s


class Solution:

	def removeDuplicates(self, arr):
		res = []
		x = set()
		for i in range(len(arr)):
			if arr[i] not in x:
				res.append(arr[i])
				x.add(arr[i])
		return res


class Solution:

	def removeDuplicates(self, arr):
		res = []
		prod = 1
		for i in range(len(arr)):
			if prod % arr[i] != 0:
				res.append(arr[i])
				prod *= arr[i]
		return res


class Solution:

	def removeDuplicates(self, arr):
		r = []
		d = {}
		for i in arr:
			if i not in d.keys():
				r.append(i)
				d[i] = 1
		return r


class Solution:

	def removeDuplicates(self, arr):
		ans = []
		dibba = {}
		for i in arr:
			if i not in dibba:
				ans.append(i)
				dibba[i] = 1
		return ans


from collections import OrderedDict

class Solution:

	def removeDuplicates(self, arr):
		A = []
		table = OrderedDict()
		for i in arr:
			if i not in table:
				table[i] = 1
				A.append(i)
		return A


class Solution:

	def removeDuplicates(self, arr):
		dp = [0] * 101
		l = 0
		for i in range(len(arr)):
			if dp[arr[i]] == False:
				dp[arr[i]] = True
				arr[l] = arr[i]
				l += 1
		return arr[:l]