Given an array of integers which may or may not contain duplicate elements. Your task is to removing duplicate elements, if present.
Example 1:
Input:
N = 6
A[] = {1, 2, 3, 1, 4, 2}
Output: 
1 2 3 4
Example 2:
Input:
N = 4
A[] = {1, 2, 3, 4}
Output: 
1 2 3 4
Your Task:  
You don't need to read input or print anything. Your task is to complete the function removeDuplicate() which takes the array A[] and its size N as inputs and returns an array with no duplicate element present, in the same order as input.
 
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

class Solution:
    def removeDuplicate(self, A, N):
        # code here
    



Solutions:
from collections import Counter

class Solution:

	def removeDuplicate(self, A, N):
		l = []
		d = {}
		for i in A:
			d[i] = d.get(i, 1)
		for ele in A:
			if d[ele] == 1:
				l.append(ele)
				d[ele] -= 1
		return l


class Solution:

	def removeDuplicate(self, A, N):
		(dup, ans) = (set(), [])
		for i in A:
			if i not in dup:
				dup.add(i)
				ans += [i]
		return ans


class Solution:

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


class Solution:

	def removeDuplicate(self, A, N):
		a = {}
		b = []
		for i in range(N):
			a[A[i]] = a.get(A[i], 0) + 1
			if a[A[i]] < 2:
				b.append(A[i])
		return b


class Solution:

	def removeDuplicate(self, A, N):
		l1 = []
		d1 = set()
		for i in A:
			if i not in d1:
				d1.add(i)
				l1 += [i]
		return l1


class Solution:

	def removeDuplicate(self, A, N):
		unique_set = set()
		result = []
		for i in range(N):
			if A[i] not in unique_set:
				unique_set.add(A[i])
				result.append(A[i])
		return result


class Solution:

	def removeDuplicate(self, A, N):
		(lst, B) = ([], set(A))
		for i in tuple(A):
			if i in B:
				lst.append(i)
				B.remove(i)
		return lst


class Solution:

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


class Solution:

	def removeDuplicate(self, A, N):
		d = {}
		for i in A:
			d[i] = d.get(i, 1)
		l = []
		for i in A:
			if d[i] == 1:
				l.append(i)
				d[i] -= 1
		return l


class Solution:

	def removeDuplicate(self, A, N):
		mp = {i: 0 for i in A}
		arr = []
		for i in range(N):
			if mp[A[i]] == 0:
				arr.append(A[i])
				mp[A[i]] = 1
		return arr


class Solution:

	def removeDuplicate(self, A, N):
		p = []
		dict_ = {}
		for elem in A:
			dict_.update({elem: dict_.get(elem, 0) + 1})
			p.append(elem) if dict_[elem] == 1 else None
		return p


class Solution:

	def removeDuplicate(self, A, N):
		d = {}
		for i in A:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		c = []
		for i in A:
			if d[i] > 0:
				c += [i]
				d[i] = 0
		return c


class Solution:

	def removeDuplicate(self, A, N):
		di = {}
		for i in A:
			di[i] = di.get(i, 1)
		li = []
		for i in A:
			if di[i] == 1:
				li.append(i)
				di[i] -= 1
		return li


class Solution:

	def removeDuplicate(self, A, N):
		s = set()
		res = []
		for i in A:
			if i not in s:
				s.add(i)
				res.append(i)
		return res


class Solution:

	def removeDuplicate(self, A, N):
		set_A = set(A)
		list_A = []
		for i in A:
			if i in set_A:
				list_A.append(i)
				set_A.remove(i)
		return list_A


class Solution:

	def removeDuplicate(self, A, N):
		dic = {}
		for i in A:
			dic[i] = 1 + dic.get(i, 0)
		arr = []
		for i in A:
			if i in dic:
				arr.append(i)
				dic.pop(i)
		return arr


class Solution:

	def removeDuplicate(self, A, N):
		k = set()
		l = []
		for j in A:
			if j not in k:
				k.add(j)
				l.append(j)
		return l


class Solution:

	def removeDuplicate(self, A, N):
		seen = set()
		result = []
		for a in A:
			if a not in seen:
				result.append(a)
				seen.add(a)
		return result


class Solution:

	def removeDuplicate(self, A, N):
		hmap = {}
		res = []
		for n in A:
			if n not in hmap:
				hmap[n] = True
				res.append(n)
		return res


from collections import OrderedDict

class Solution:

	def removeDuplicate(self, A, N):
		d = OrderedDict()
		for e in A:
			d[e] = d.get(e, 0) + 1
		return d.keys()


class Solution:

	def quicksort(self, arr, low, high):
		if low < high:
			p = self.partition(arr, low, high)
			self.quicksort(arr, low, p - 1)
			self.quicksort(arr, p + 1, high)

	def partition(self, arr, low, high):
		pivot = arr[high]
		i = low - 1
		for j in range(low, high):
			if arr[j] < pivot:
				i += 1
				(arr[i], arr[j]) = (arr[j], arr[i])
		(arr[i + 1], arr[high]) = (arr[high], arr[i + 1])
		return i + 1

	def removeDuplicate(self, A, N):
		dup = set()
		ans = []
		for i in range(N):
			if A[i] not in dup:
				dup.add(A[i])
				ans += [A[i]]
		return ans


class Solution:

	def removeDuplicate(self, A, N):
		li1 = [0] * (max(A) + 1)
		li2 = []
		d = {}
		for i in A:
			d[i] = d.get(i, 0) + 1
		for i in A:
			if d.get(i) > 1 and li1[i] == 0:
				li2.append(i)
				li1[i] = 1
			elif d.get(i) == 1:
				li2.append(i)
		return li2


class Solution:

	def removeDuplicate(self, A, N):
		d = {}
		ans = []
		for i in range(len(A)):
			if d.get(A[i], -1) == -1:
				ans.append(A[i])
				d[A[i]] = 1
		return ans


class Solution:

	def removeDuplicate(self, A, N):
		visited = {}
		res = []
		for i in range(N):
			if A[i] not in visited:
				res.append(A[i])
				visited[A[i]] = 1
		return res


class Solution:

	def removeDuplicate(self, A, N):
		st = set()
		ans = []
		for v in A:
			if not v in st:
				st.add(v)
				ans.append(v)
		return ans


from collections import OrderedDict

class Solution:

	def removeDuplicate(self, A, N):
		res = list(OrderedDict.fromkeys(A))
		return res


class Solution:

	def removeDuplicate(self, A, N):
		d = {}
		ans = []
		for i in A:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
			if d[i] == 1:
				ans.append(i)
		return ans


class Solution:

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


class Solution:

	def removeDuplicate(self, a, n):
		s = set()
		res = []
		for num in a:
			if num not in s:
				res.append(num)
				s.add(num)
		return res


class Solution:

	def removeDuplicate(self, A, N):
		s = {}
		r = []
		for j in A:
			if j not in s.keys():
				r.append(j)
				s[j] = j
			else:
				continue
		return r


from collections import Counter

class Solution:

	def removeDuplicate(self, A, N):
		d = Counter(A)
		x = []
		for i in A:
			if d[i] >= 1:
				x.append(i)
				d[i] = 0
			else:
				pass
		return x


class Solution:

	def removeDuplicate(self, A, N):
		l = [-1] * 100000
		l1 = []
		for i in A:
			if l[i] == -1:
				l1.append(i)
				l[i] = 1
		return l1


class Solution:

	def removeDuplicate(self, A, N):
		di = {}
		li = []
		for i in range(N):
			if A[i] not in di.keys():
				di[A[i]] = A[i]
				li.append(A[i])
		return li


class Solution:

	def removeDuplicate(self, A, N):
		f = {}
		g = []
		for i in A:
			if i in f:
				f[i] += 1
			else:
				f[i] = 1
				g.append(i)
		return g


class Solution:

	def removeDuplicate(self, A, N):
		dic = {}
		l = []
		for i in A:
			if i not in dic:
				dic[i] = 1
				l.append(i)
		return l


from collections import OrderedDict

class Solution:

	def removeDuplicate(self, A, N):
		d = OrderedDict()
		for i in A:
			d[i] = 0
		res = []
		return d.keys()


class Solution:

	def removeDuplicate(self, A, N):
		max = 0
		for i in A:
			if max < i:
				max = i
		hash = [-1] * (max + 1)
		for i in A:
			hash[i] = 0
		res = []
		for i in A:
			if hash[i] == 0:
				res.append(i)
				hash[i] = 1
		return res


from collections import OrderedDict

class Solution:

	def removeDuplicate(self, A, N):
		o = OrderedDict()
		for item in A:
			o[item] = 1
		return list(o.keys())


class Solution:

	def removeDuplicate(self, A, N):
		h = set()
		r = [i for i in A if not (i in h or h.add(i))]
		return r


class Solution:

	def removeDuplicate(self, A, N):
		h = set()
		r = [i for i in A if not (i in h or h.add(i))]
		v = []
		d = dict()
		for i in A:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		for i in r:
			v.append(i)
		return v


class Solution:

	def removeDuplicate(self, A, N):
		list_A = []
		set_A = set()
		for i in A:
			if i not in set_A:
				list_A.append(i)
				set_A.add(i)
		return list_A


class Solution:

	def removeDuplicate(self, A, N):
		lis = []
		dic = dict()
		for i in A:
			if i not in dic:
				dic[i] = 1
				lis.append(i)
		return lis


class Solution:

	def removeDuplicate(self, A, N):
		hash = {}
		for i in A:
			hash[i] = hash.get(i, 1)
		list = []
		for i in A:
			if hash[i] == 1:
				list.append(i)
				hash[i] -= 1
		return list


class Solution:

	def removeDuplicate(self, A: list, N: int) -> list:
		seen = set()
		B = []
		for i in range(N):
			if A[i] not in seen:
				B.append(A[i])
				seen.add(A[i])
		return B


class Solution:

	def removeDuplicate(self, A, N):
		freq = {}
		result = []
		for i in range(0, N):
			if A[i] not in freq.keys():
				x = A[i]
				freq[x] = True
				result.append(A[i])
		return result


class Solution:

	def removeDuplicate(self, A, N):
		set = {}
		l = []
		for i in A:
			if not set.get(i):
				l.append(i)
				set[i] = True
		return l


class Solution:

	def removeDuplicate(self, A, N):
		map = {}
		res = []
		for element in A:
			if map.get(element) is None:
				res.append(element)
				map[element] = True
		return res


class Solution:

	def removeDuplicate(self, A, N):
		dic = {}
		i = 0
		while i < len(A):
			if A[i] not in dic:
				dic[A[i]] = 1
			else:
				A.pop(i)
				i -= 1
			i += 1
		return A


class Solution:

	def removeDuplicate(self, a, n):
		di = {}
		for i in a:
			di[i] = di.get(i, 1)
		l = []
		for i in a:
			if di[i] == 1:
				l.append(i)
				di[i] -= 1
		return l