In a party of N people, each person is denoted by an integer. Couples are represented by the same number. Find out the only single person in the party of couples.
Example 1:
Input: N = 5
arr = {1, 2, 3, 2, 1}
Output: 3
Explaination: Only the number 3 is single.
Example 2:
Input: N = 11
arr = {1, 2, 3, 5, 3, 2, 1, 4, 5, 6, 6}
Output: 4
Explaination: 4 is the only single.
Your Task:
You do not need to read input or print anything. Your task is to complete the function findSingle() which takes the size of the array N and the array arr[] as input parameters and returns the only single person.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{4}
1 ≤ arr[i] ≤ 10^{6}

Difficulty: EASY
Tags: Bit manipulation

Data structures
Skill types: Bit manipulation

Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def findSingle(self, N, arr):
        # code here

Solutions:
class Solution:

	def findSingle(self, N, arr):
		for i in range(N):
			if arr.count(arr[i]) == 1:
				return arr[i]


class Solution:

	def findSingle(self, N, arr):
		count_dict = {}
		for i in arr:
			if i in count_dict:
				count_dict[i] += 1
			else:
				count_dict[i] = 1
		for (person, count) in count_dict.items():
			if count == 1:
				return person


class Solution:

	def findSingle(self, n, a):
		for i in a:
			if a.count(i) == 1:
				return i


class Solution:

	def findSingle(self, N, arr):
		for i in arr:
			if arr.count(i) < 2:
				return i


class Solution:

	def findSingle(self, N, arr):
		diction = {}
		for num in arr:
			if num in diction:
				diction[num] += 1
			else:
				diction[num] = 1
		return list(diction.keys())[list(diction.values()).index(1)]


class Solution:

	def findSingle(self, N, arr):
		count = 0
		for i in range(len(arr)):
			count ^= arr[i]
		return count


class Solution:

	def findSingle(self, N, arr):
		s = set(arr)
		for i in s:
			if arr.count(i) == 1:
				return i


class Solution:

	def findSingle(self, N, arr):
		new_arr = set(arr)
		ans = 0
		for i in arr:
			if arr.count(i) == 1:
				ans = i
		return ans


class Solution:

	def findSingle(self, N, a):
		s = 0
		for i in range(N):
			s = s ^ a[i]
		return s


class Solution:

	def findSingle(self, N, a):
		singleELe = -1
		for i in range(N):
			if a[i] not in a[:i] and a[i] not in a[i + 1:]:
				singleELe = a[i]
		return singleELe


class Solution:

	def findSingle(self, N, arr):
		for i in range(N):
			c = 0
			for j in range(N):
				if i == j:
					pass
				elif arr[i] == arr[j]:
					c += 1
					break
			if c == 0:
				return arr[i]


class Solution:

	def findSingle(self, N, arr):
		dic = {}
		for e in arr:
			try:
				c = dic[e]
				dic[e] = c + 1
			except:
				dic[e] = 1
		for (i, v) in dic.items():
			if v == 1:
				return i
		return -1


class Solution:

	def findSingle(self, N, arr):
		single = [x for x in arr if arr.count(x) == 1][0]
		return single


class Solution:

	def findSingle(self, N, arr):
		pc = {}
		for i in arr:
			if i in pc.keys():
				pc[i] -= 1
			else:
				pc[i] = 1
		for (k, v) in pc.items():
			if v > 0:
				return k
		return -1


class Solution:

	def findSingle(self, N, arr):
		dic = {}
		for i in range(N):
			dic[arr[i]] = dic.get(arr[i], 0) + 1
		for (key, value) in dic.items():
			if value == 1:
				return key
				break


class Solution:

	def findSingle(self, N, arr):
		x = 0
		for i in range(0, N):
			x = x ^ arr[i]
		return x


from collections import Counter

class Solution:

	def findSingle(self, N, arr):
		x = Counter(arr)
		for i in x.keys():
			if x[i] == 1:
				return i
		return 0


class Solution:

	def findSingle(self, n, arr):
		for index in range(n):
			for index1 in range(n):
				if arr[index1] == arr[index] and index != index1:
					break
				elif index1 == n - 1:
					return arr[index]


class Solution:

	def findSingle(self, N, arr):
		xor = 0
		for i in arr:
			xor ^= i
		return xor


class Solution:

	def findSingle(self, N, arr):
		single = [i for i in arr if arr.count(i) == 1]
		return single.pop()


class Solution:

	def findSingle(self, N, arr):
		m = []
		for i in arr:
			k = list(arr)
			c = k.count(i)
			if c < 2:
				m.append(i)
		j = ' '.join(map(str, m))
		return j


class Solution:

	def findSingle(self, N, arr):
		freq = {}
		for num in arr:
			freq[num] = freq.get(num, 0) + 1
		for (key, value) in freq.items():
			if value == 1:
				return key
		return -1


class Solution:

	def findSingle(self, N, arr):
		sum = 0
		res = 0
		for i in range(N):
			res = res ^ arr[i]
		return res


class Solution:

	def findSingle(self, N, arr):
		seen = {}
		for i in arr:
			if i in seen:
				seen[i] += 1
			else:
				seen[i] = 1
		for i in seen:
			if seen[i] == 1:
				return i
		return arr[-1]


class Solution:

	def findSingle(self, N, arr):
		counter = 0
		for i in arr:
			x = arr.count(i)
			if x == 1:
				counter = i
		return counter


class Solution:

	def findSingle(self, N, arr):
		from collections import Counter
		ans = Counter(arr)
		for i in ans:
			if ans[i] == 1:
				return i


class Solution:

	def findSingle(self, N, arr):
		ans = []
		for i in arr:
			if i in ans:
				ans.remove(i)
			else:
				ans.append(i)
		return ans[0]


class Solution:

	def findSingle(self, N, arr):
		arr.sort()
		s = 0
		for i in arr:
			s ^= i
		return s


class Solution:

	def findSingle(self, N, arr):
		dic = {}
		for i in arr:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		lst = []
		for (i, v) in dic.items():
			if v == 1:
				lst.append(i)
		return lst[0]


class Solution:

	def findSingle(self, N, arr):
		counts = {}
		for num in arr:
			if num in counts:
				counts[num] += 1
			else:
				counts[num] = 1
		for (num, count) in counts.items():
			if count == 1:
				return num


class Solution:

	def findSingle(self, N, arr):
		result = 0
		for num in arr:
			result ^= num
		return result


class Solution:

	def findSingle(self, N, arr):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] = d[i] + 1
		for i in d:
			if d[i] == 1:
				return i


from collections import Counter

class Solution:

	def findSingle(self, N, arr):
		set1 = Counter(arr)
		for (i, v) in set1.items():
			if v == 1:
				return i


from collections import Counter

class Solution:

	def findSingle(self, N, arr):
		dictN = dict(Counter(arr))
		for (key, value) in dictN.items():
			if value == 1:
				return key


class Solution:

	def findSingle(self, N, arr):
		arr = sorted(arr)
		for i in range(0, N, 2):
			if i + 1 < N:
				for j in range(i + 1, i + 2):
					if arr[i] != arr[j]:
						return arr[i]
			else:
				return arr[i]


class Solution:

	def findSingle(self, N, arr):
		c = 0
		for i in arr:
			if arr.count(i) == 1:
				return i


class Solution:

	def findSingle(self, N, arr):
		li = list()
		for x in arr:
			if x not in li:
				li.append(x)
			else:
				li.remove(x)
		return li[0]


class Solution:

	def findSingle(self, N, arr):
		hashmap = {}
		ans = 0
		for i in range(N):
			hashmap[arr[i]] = hashmap.get(arr[i], 0) + 1
		for i in range(N):
			if hashmap[arr[i]] == 1:
				ans = arr[i]
		return ans


class Solution:

	def findSingle(self, N, arr):
		ans = 0
		for a in arr:
			ans = ans ^ a
		return ans


class Solution:

	def findSingle(self, N, arr):
		couples = {}
		for a in arr:
			couples[a] = couples.get(a, 0) + 1
		for couple in couples:
			if couples[couple] == 1:
				return couple


class Solution:

	def findSingle(self, N, arr):
		k = list(set(arr))
		for i in k:
			if arr.count(i) == 1:
				return i


from collections import Counter

class Solution:

	def findSingle(self, n, arr):
		a = Counter(arr)
		x_val = list(a.values())
		x_key = list(a.keys())
		for i in range(n):
			if x_val[i] == 1:
				return x_key[i]


class Solution:

	def findSingle(self, N, arr):
		d = {}
		for elm in arr:
			if elm in d:
				d[elm] = d[elm] + 1
			else:
				d[elm] = 1
		for key in d:
			if d[key] == 1:
				return key
		return -1


class Solution:

	def findSingle(self, N, arr):
		k = arr[0] | arr[0]
		for i in range(1, N):
			k = k ^ arr[i]
		return k


class Solution:

	def findSingle(self, N, arr):
		aux = -1
		for i in range(0, N):
			aux = arr[i]
			encontrado = False
			for j in range(0, N):
				if aux == arr[j] and (not i == j):
					encontrado = True
					break
			if not encontrado:
				return aux
		return -1


class Solution:

	def findSingle(self, N, arr):
		uniquelist = []
		duplicatelist = []
		for i in arr:
			if i not in uniquelist:
				uniquelist.append(i)
			else:
				duplicatelist.append(i)
		for j in arr:
			if j not in duplicatelist:
				return j


class Solution:

	def findSingle(self, N, arr):
		mp = dict()
		for i in range(N):
			if arr[i] in mp.keys():
				mp[arr[i]] += 1
			else:
				mp[arr[i]] = 1
		for x in mp:
			if mp[x] == 1:
				return x


class Solution:

	def findSingle(self, N, arr):
		x = 0
		for n in arr:
			x ^= n
		return x


class Solution:

	def findSingle(self, n, arr):
		ctr = 0
		for i in arr:
			if arr.count(i) == 1:
				ctr = i
		return ctr


class Solution:

	def findSingle(self, N, arr):
		arr.sort()
		for i in range(0, N - 1, 2):
			if arr[i] == arr[i + 1]:
				pass
			else:
				return arr[i]
		else:
			return arr[N - 1]


class Solution:

	def findSingle(self, N, arr):
		count = [0] * 10 ** 6
		for i in range(N):
			count[arr[i]] += 1
		for j in range(10 ** 6):
			if count[j] == 1:
				return j