Given an array Arr of positive integers of size N where every element appears even times except for one. Find that number occuring odd number of times.
Example 1:
Input: 
N = 5
Arr[] = {1, 1, 2, 2, 2}
Output: 2
Explanation: In the given array all
element appear two times except 2
which appears thrice.
Example 2:
Input: 
N = 7
Arr[] = {8, 8, 7, 7, 6, 6, 1}
Output: 1
Explanation: In the given array all
element appear two times except 1
which appears once.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function getSingle() which takes the array of integers arr[] and n as parameters and returns a integer denoting the answer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 10^{7}
0 <= Arr_{i} <= 10^{8}

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

Starter code:
#User function Template for python3



class Solution:

    

    def getSingle(self,arr, n):

        # code here



Solutions:
from collections import Counter

class Solution:

	def getSingle(self, arr, n):
		a = Counter(arr)
		output = ''
		for (keys, values) in a.items():
			if values % 2 != 0:
				output += str(keys)
		if len(output) > 0:
			return output
		else:
			return 0


class Solution:

	def getSingle(self, arr, n):
		res = 0
		for num in arr:
			res = num ^ res
		return res


class Solution:

	def getSingle(self, arr, n):
		freq = {}
		for i in arr:
			if i in freq:
				freq[i] += 1
			else:
				freq[i] = 1
		for i in freq:
			if freq[i] % 2 != 0:
				return i
		return 0


class Solution:

	def getSingle(self, arr, n):
		ans = 0
		for x in arr:
			ans ^= x
		return ans


class Solution:

	def getSingle(self, arr, n):
		dict_ = {}
		for elem in arr:
			dict_.update({elem: dict_.get(elem, 0) + 1})
		for (key, value) in dict_.items():
			if value % 2 == 1:
				return key
		return 0


class Solution:

	def getSingle(self, arr, n):
		d = {}
		num = 0
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		for i in d:
			if d[i] % 2 != 0:
				num = i
		return num


class Solution:

	def getSingle(self, arr, n):
		sing = 0
		for i in arr:
			sing = sing ^ i
		return sing


class Solution:

	def getSingle(self, arr, n):
		h = {}
		for i in arr:
			if i not in h:
				h[i] = 1
			else:
				h[i] += 1
		for i in arr:
			if h[i] % 2 != 0:
				return i
		return 0


class Solution:

	def getSingle(self, arr, n):
		output = 0
		for item in arr:
			output ^= item
		return output


class Solution:

	def getSingle(self, arr, n):
		table = {}
		for i in arr:
			if i in table:
				table[i] += 1
			else:
				table[i] = 1
		for j in table:
			if table[j] % 2 != 0:
				return j
		return 0


class Solution:

	def getSingle(self, arr, n):
		xor = 0
		for i in range(n):
			xor = xor ^ arr[i]
		return xor


class Solution:

	def getSingle(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		for (k, v) in d.items():
			if v % 2 != 0:
				return k
		return 0


class Solution:

	def getSingle(self, arr, n):
		d = {}
		for i in range(n):
			if arr[i] in d:
				d[arr[i]] += 1
			else:
				d[arr[i]] = 1
		for (i, j) in d.items():
			if j % 2 != 0:
				return i
		return 0


class Solution:

	def getSingle(self, nums, n):
		hm = {}
		for x in range(n):
			if nums[x] not in hm:
				hm[nums[x]] = 1
			else:
				hm[nums[x]] += 1
		for x in hm:
			if hm[x] % 2 != 0:
				return x
		return 0


class Solution:

	def getSingle(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		a = 0
		for i in set(arr):
			if d[i] % 2 == 1:
				a = i
		return a


from collections import Counter

class Solution:

	def getSingle(self, arr, n):
		a = Counter(arr)
		for i in range(len(arr)):
			if a[arr[i]] % 2 != 0 or a[arr[i]] == 1:
				return arr[i]
		return 0


class Solution:

	def getSingle(self, arr, n):
		x = 0
		p = []
		for i in arr:
			x = x ^ i
		return x


class Solution:

	def getSingle(self, arr, n):
		result = 0
		for i in range(0, len(arr)):
			result = result ^ arr[i]
		return result


class Solution:

	def getSingle(self, arr, n):
		ans = 0
		for i in range(0, n):
			ans ^= arr[i]
			i += 1
		return ans


class Solution:

	def getSingle(self, arr, n):
		res = arr[0]
		for i in range(1, len(arr)):
			res = res ^ arr[i]
		return res


from collections import Counter

class Solution:

	def getSingle(self, arr, n):
		x = Counter(arr)
		ans = ''
		for (k, v) in x.items():
			if v % 2 != 0:
				ans += str(k)
		if len(ans) > 0:
			return ans
		else:
			return 0


import collections

class Solution:

	def getSingle(self, arr, n):
		c = collections.Counter(arr)
		for i in c.keys():
			if c[i] % 2 == 1:
				return i
		return 0


class Solution:

	def getSingle(self, arr, n):
		numbers = dict()
		for i in arr:
			if i in numbers:
				del numbers[i]
			else:
				numbers[i] = 1
		if len(numbers) > 0:
			return list(numbers.keys())[0]
		else:
			return 0


class Solution:

	def getSingle(self, arr, n):
		num = []
		d = {}
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		for i in d:
			if d[i] % 2 != 0:
				return list(d.keys())[list(d.values()).index(d[i])]
		else:
			return 0


class Solution:

	def getSingle(self, arr, n):
		d = {}
		for ele in arr:
			d[ele] = 0
		for ele in arr:
			d[ele] = d[ele] + 1
		for (k, v) in d.items():
			if v % 2 != 0:
				return k
		return 0


class Solution:

	def getSingle(self, arr, n):
		from collections import Counter
		d = Counter(arr)
		for x in set(arr):
			if d[x] % 2 != 0:
				return x
				break
		return 0


class Solution:

	def getSingle(self, arr, n):
		bc = [0 for i in range(33)]

		def bin(num):
			if num < 0:
				num = -num
				bc[32] = -bc[32]
			i = 31
			while num:
				j = num % 2
				bc[i] = bc[i] + j
				i = i - 1
				num = num // 2

		def nb(bc):
			i = 0
			j = 31
			b = 0
			while j >= 0:
				b = b + bc[j] * 2 ** i
				i = i + 1
				j = j - 1
			return b
		for i in arr:
			bin(i)
		for i in range(33):
			bc[i] = bc[i] % 2
		b = nb(bc)
		if bc[32] == 1:
			b = -b
		return b


class Solution:

	def getSingle(self, arr, n):
		dic = {}
		for i in arr:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		for i in dic.keys():
			if dic[i] % 2 != 0:
				return i
		return 0


class Solution:

	def getSingle(self, arr, n):
		dic = {}
		ls = list(set(arr))
		for e in ls:
			dic[e] = 0
		for e in arr:
			v = dic[e]
			v = v + 1
			dic[e] = v
		for (x, y) in dic.items():
			if y % 2 != 0:
				return x
		return 0


class Solution:

	def getSingle(self, arr, n):
		ans = 0
		from collections import Counter
		f = Counter(arr)
		for i in f:
			if f[i] % 2 != 0:
				ans = i
				break
		return ans


from collections import Counter

class Solution:

	def getSingle(self, arr, n):
		di = Counter(arr)
		for i in arr:
			if di[i] % 2 != 0:
				return i
		return 0


class Solution:

	def getSingle(self, a, n):
		ans = 0
		for i in range(n):
			ans ^= a[i]
		return ans


class Solution:

	def getSingle(self, a, n):
		d = {}
		for i in range(n):
			if a[i] not in d:
				d[a[i]] = 1
			else:
				d[a[i]] += 1
		for k in d:
			if d[k] % 2 == 1:
				return k
		return 0


class Solution:

	def getSingle(self, arr, n):
		d = dict.fromkeys(arr, 0)
		for i in arr:
			d[i] = d[i] + 1
		for j in d:
			if d[j] % 2 != 0:
				return j
		return 0


class Solution:

	def getSingle(self, arr, n):
		c = 1
		arr.sort()
		for i in range(n - 1):
			if arr[i] == arr[i + 1]:
				c += 1
			else:
				if c % 2 != 0:
					return arr[i]
				c = 1
		a = arr.count(arr[-1])
		if a % 2 != 0:
			return arr[-1]
		else:
			return 0


class Solution:

	def getSingle(self, arr: list, n: int) -> int:
		counter = {}
		for i in range(n):
			if arr[i] in counter:
				counter[arr[i]] += 1
			else:
				counter[arr[i]] = 1
		for (key, value) in counter.items():
			if value % 2:
				return key
		return 0


class Solution:

	def getSingle(self, arr, n):
		dict = {}
		for i in range(n):
			dict[arr[i]] = dict.get(arr[i], 0) + 1
		for key in dict:
			value = dict[key]
			if value % 2 != 0:
				return key
		return 0


class Solution:

	def getSingle(self, arr, n):
		dic = {}
		k = 0
		for i in arr:
			if i not in dic:
				dic[i] = 1
			else:
				dic[i] += 1
		for i in arr:
			if dic[i] % 2 != 0:
				k = i
				break
		return k