Given an unsorted array, Arr[] of size N and that contains even number of occurrences for all numbers except two numbers. Find the two numbers in decreasing order which has odd occurrences.
Example 1:
Input:
N = 8
Arr = {4, 2, 4, 5, 2, 3, 3, 1}
Output: {5, 1} 
Explaination: 5 and 1 have odd occurrences.
Example 2:
Input:
N = 8
Arr = {1 7 5 7 5 4 7 4}
Output: {7, 1}
Explaination: 7 and 1 have odd occurrences.
Your Task:
You don't need to read input or print anything. Your task is to complete the function twoOddNum() which takes the array Arr[] and its size N as input parameters and returns the two numbers in decreasing order which have odd occurrences.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
2 ≤ N ≤ 10^{6}
1 ≤ Arr_{i} ≤ 10^{12}

Difficulty: MEDIUM
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:

    def twoOddNum(self, Arr, N):

        # code here



Solutions:
class Solution:

	def twoOddNum(self, Arr, N):
		d = {}
		l = []
		for i in Arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		for (i, j) in d.items():
			if j % 2 != 0:
				l.append(i)
		l = sorted(l)
		return l[::-1]


class Solution:

	def twoOddNum(self, t, n):
		a = 0
		for i in range(n):
			a ^= t[i]
		x = a & -a
		y = 0
		z = 0
		for i in range(n):
			if t[i] & x:
				y ^= t[i]
			else:
				z ^= t[i]
		return [max(y, z), min(y, z)]


class Solution:

	def twoOddNum(self, a, N):
		xor = 0
		x1 = 0
		x0 = 0
		for i in range(N):
			xor = xor ^ a[i]
		cnt = 0
		while xor:
			if xor & 1:
				break
			cnt += 1
			xor = xor >> 1
		for i in a:
			if i & 1 << cnt:
				x1 = x1 ^ i
			else:
				x0 = x0 ^ i
		if x0 < x1:
			return (x1, x0)
		return (x0, x1)


class Solution:

	def twoOddNum(self, Arr, N):
		op = []
		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:
				op.append(i)
		op.sort(reverse=True)
		return (op[0], op[1])


class Solution(object):

	def twoOddNum(self, nums, N):
		xor = 0
		for num in nums:
			xor ^= num
		index = 0
		while xor:
			if xor & 1 == 1:
				break
			index += 1
			xor >>= 1
		xor1 = xor2 = 0
		mask = 1 << index
		for num in nums:
			if num & mask:
				xor1 ^= num
			else:
				xor2 ^= num
		if xor1 > xor2:
			return [xor1, xor2]
		else:
			return [xor2, xor1]


class Solution:

	def twoOddNum(self, arr, n):
		xor = 0
		for i in range(n):
			xor = xor ^ arr[i]
		copy = xor
		pos = 1
		while copy % 2 == 0:
			copy = copy >> 1
			pos += 1
		xor = 2 ** (pos - 1)
		first = 0
		second = 0
		for i in range(n):
			if xor & arr[i]:
				first ^= arr[i]
			else:
				second ^= arr[i]
		if first > second:
			return [first, second]
		else:
			return [second, first]


class Solution:

	def twoOddNum(self, Arr, N):
		xor_all = 0
		for ele in Arr:
			xor_all ^= ele
		first_setbit = xor_all & ~xor_all + 1
		num1 = xor_all
		for ele in Arr:
			if first_setbit & ele:
				num1 = num1 ^ ele
		num2 = xor_all ^ num1
		if num1 < num2:
			return [num2, num1]
		return [num1, num2]


from collections import Counter

class Solution:

	def twoOddNum(self, Arr, N):
		e = Counter(Arr)
		v = []
		c = 0
		for j in e:
			if e[j] % 2 != 0:
				if j > c:
					v.insert(0, j)
					c = j
				else:
					v.append(j)
		return v


class Solution:

	def twoOddNum(self, Arr, N):
		x_y = 0
		for ele in Arr:
			x_y = x_y ^ ele
		setval = x_y & ~x_y + 1
		x = x_y
		for ele in Arr:
			if ele & setval == setval:
				x = x ^ ele
		y = x_y ^ x
		if x > y:
			return [x, y]
		return [y, x]


class Solution:

	def twoOddNum(self, Arr, N):
		(odd1, odd2) = (0, 0)
		xor = Arr[0]
		for i in range(1, N):
			xor ^= Arr[i]
		xor = xor & ~(xor - 1)
		for i in range(N):
			if Arr[i] & xor:
				odd1 ^= Arr[i]
			else:
				odd2 ^= Arr[i]
		if odd1 > odd2:
			return [odd1, odd2]
		return [odd2, odd1]


from collections import Counter

class Solution:

	def twoOddNum(self, Arr, N):
		l = []
		a = Counter(Arr)
		for i in range(N):
			if a[Arr[i]] % 2 != 0:
				l.append(Arr[i])
		s = list(set(l))
		s.sort()
		return s[::-1]


class Solution:

	def twoOddNum(self, Arr, N):
		xor2 = Arr[0]
		x = 0
		y = 0
		for i in range(1, N):
			xor2 = xor2 ^ Arr[i]
		set_bit_no = xor2 & ~(xor2 - 1)
		for i in range(N):
			if Arr[i] & set_bit_no:
				x = x ^ Arr[i]
			else:
				y = y ^ Arr[i]
		v = [max(x, y), min(x, y)]
		return v


class Solution:

	def twoOddNum(self, Arr, N):
		res = 0
		res1 = 0
		res2 = 0
		for i in range(N):
			res = res ^ Arr[i]
		res = res & ~(res - 1)
		for i in range(N):
			if Arr[i] & res:
				res1 ^= Arr[i]
			else:
				res2 ^= Arr[i]
		if res2 > res1:
			return (res2, res1)
		return (res1, res2)


class Solution:

	def twoOddNum(self, Arr, N):
		o = []
		d = {}
		for i in range(N):
			if Arr[i] not in d:
				d[Arr[i]] = 1
			else:
				d[Arr[i]] += 1
		for i in range(N):
			if d[Arr[i]] % 2 != 0:
				o.append(Arr[i])
		s = set(o)
		l = list(s)
		l.sort()
		l.reverse()
		return l


class Solution:

	def twoOddNum(self, Arr, N):
		x = 0
		for i in range(N):
			x = x ^ Arr[i]
		c = 0
		while x:
			if x & 1:
				break
			c += 1
			x = x >> 1
		(x1, x2) = (0, 0)
		for i in range(N):
			if Arr[i] & 1 << c:
				x1 = x1 ^ Arr[i]
			else:
				x2 = x2 ^ Arr[i]
		if x1 > x2:
			return [x1, x2]
		else:
			return [x2, x1]


from collections import Counter

class Solution:

	def twoOddNum(self, arr, N):
		count = Counter(arr)
		ans = []
		for (key, val) in count.items():
			if val % 2 == 1:
				ans.append(key)
		ans.sort()
		ans.reverse()
		return ans


class Solution:

	def twoOddNum(self, Arr, N):
		axorb = 0
		for i in Arr:
			axorb = axorb ^ i
		x = 0
		while True:
			if 1 << x & axorb:
				break
			x = x + 1
		decider = 1 << x
		num1 = 0
		num2 = 0
		for i in Arr:
			if i & decider:
				num1 = num1 ^ i
			else:
				num2 = num2 ^ i
		ans = []
		if num1 > num2:
			ans = (num1, num2)
		else:
			ans = (num2, num1)
		return ans


class Solution:

	def twoOddNum(self, arr, N):
		arr.sort()
		m = {}
		for i in range(N):
			if arr[i] not in m:
				m[arr[i]] = 0
			m[arr[i]] += 1
		out = []
		for x in m:
			if m[x] % 2 != 0:
				out.append(x)
		out.sort(reverse=True)
		return out


import collections

class Solution:

	def twoOddNum(self, Arr, N):
		m = collections.Counter(Arr)
		list1 = []
		for i in m:
			if m[i] % 2 != 0:
				list1.append(i)
		q = sorted(list1)
		return q[::-1]


class Solution:

	def twoOddNum(self, Arr, N):
		xor = 0
		for i in Arr:
			xor = xor ^ i
		bit = 0
		while xor > 0:
			if xor & 1 == 1:
				break
			bit += 1
			xor = xor >> 1
		bit1 = []
		bit0 = []
		for num in Arr:
			if num >> bit & 1 == 1:
				bit1.append(num)
			else:
				bit0.append(num)
		x1 = 0
		x2 = 0
		for i in bit1:
			x1 = x1 ^ i
		for i in bit0:
			x2 = x2 ^ i
		if x1 > x2:
			(x1, x2) = (x2, x1)
		return [x2, x1]


from sys import maxsize

class Solution:

	def twoOddNum(self, Arr, N):
		d = {}
		for i in Arr:
			try:
				d[i]
			except:
				d[i] = 0
			d[i] += 1
		fHighest = 0
		sHighest = ~maxsize
		for i in d.keys():
			if d[i] % 2 == 1 and i > fHighest:
				sHighest = fHighest
				fHighest = i
			elif d[i] % 2 == 1 and i > sHighest:
				sHighest = i
		return [fHighest, sHighest]


class Solution:

	def twoOddNum(self, Arr, N):
		dic = {}
		lis = []
		for x in Arr:
			if x not in dic:
				dic[x] = 1
			else:
				dic[x] += 1
		for y in dic:
			if dic[y] % 2 != 0:
				lis.append(y)
		lis.sort()
		lis.reverse()
		return lis


class Solution:

	def twoOddNum(self, arr, n):
		arr.sort()
		list = []
		count = 1
		num = arr[0]
		i = 1
		while i < n:
			if num == arr[i]:
				count += 1
				i += 1
			elif count % 2 == 1:
				list.insert(0, num)
				count = 1
				num = arr[i]
				i += 1
			elif num != arr[i]:
				count = 1
				num = arr[i]
				i += 1
		if count % 2 == 1:
			list.insert(0, arr[i - 1])
		return list


class Solution:

	def twoOddNum(self, Arr, N):
		res = 0
		(res1, res2) = (0, 0)
		for i in range(N):
			res = res ^ Arr[i]
		sn = res & ~(res - 1)
		for i in range(N):
			if Arr[i] & sn != 0:
				res1 = res1 ^ Arr[i]
			else:
				res2 = res2 ^ Arr[i]
		ans = []
		m = max(res1, res2)
		n = min(res1, res2)
		ans = [m, n]
		return ans


from collections import Counter

class Solution:

	def twoOddNum(self, Arr, N):
		r = []
		k = Counter(Arr)
		for i in k:
			if k[i] % 2 == 1:
				r.append(i)
		return sorted(r, reverse=True)


class Solution:

	def twoOddNum(self, Arr, N):
		dict1 = dict()
		for i in Arr:
			if i in dict1:
				dict1[i] += 1
			else:
				dict1[i] = 1
		a = []
		for val in dict1:
			if dict1[val] % 2 != 0:
				a.append(val)
		a.sort()
		a.reverse()
		return a


from collections import Counter

class Solution:

	def twoOddNum(self, Arr, N):
		a = Counter(Arr)
		v = []
		for i in a:
			if a[i] % 2 != 0:
				v.append(i)
		return sorted(v, reverse=True)


class Solution:

	def twoOddNum(self, arr, n):
		xr = 0
		for i in range(len(arr)):
			xr ^= arr[i]
		sb = xr & ~(xr - 1)
		a1 = 0
		for i in range(len(arr)):
			if arr[i] & sb:
				a1 ^= arr[i]
		return sorted([a1, a1 ^ xr], reverse=1)


class Solution:

	def twoOddNum(self, Arr, N):
		dic = {}
		res_arr = []
		for ele in Arr:
			if ele in dic:
				dic[ele] += 1
			else:
				dic[ele] = 1
		for ele in dic:
			if dic[ele] % 2 != 0:
				res_arr.append(ele)
		res_arr.sort(reverse=True)
		return res_arr


class Solution:

	def twoOddNum(self, Arr, N):
		xor = 0
		for i in range(N):
			xor = xor ^ Arr[i]
		xor = xor & -xor
		xor1 = xor2 = 0
		for i in range(N):
			if Arr[i] & xor == 0:
				xor1 = xor1 ^ Arr[i]
			else:
				xor2 = xor2 ^ Arr[i]
		if xor1 < xor2:
			(xor1, xor2) = (xor2, xor1)
		return (xor1, xor2)


class Solution:

	def twoOddNum(self, Arr, N):
		odd = []
		dict = {}
		for i in Arr:
			if i in dict:
				dict[i] += 1
			else:
				dict[i] = 1
		for i in dict:
			if dict[i] % 2 != 0:
				odd.append(i)
		odd.sort()
		odd.reverse()
		return odd


class Solution:

	def twoOddNum(self, Arr, N):
		d = {}
		for i in Arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		s = []
		for i in set(Arr):
			if d[i] % 2 == 1:
				s.append(i)
		return sorted(s)[::-1]


class Solution:

	def twoOddNum(self, arr, N):
		n = len(arr)
		xor = 0
		for i in range(n):
			xor = xor ^ arr[i]
		cnt = 0
		while xor:
			if xor & 1 == 0:
				cnt += 1
				xor = xor >> 1
			else:
				break
		xor1 = 0
		xor2 = 0
		for i in range(n):
			if arr[i] & 1 << cnt == 0:
				xor1 = xor1 ^ arr[i]
			else:
				xor2 = xor2 ^ arr[i]
		ans = []
		ans.append(xor1)
		ans.append(xor2)
		return sorted(ans, reverse=True)


class Solution:

	def twoOddNum(self, Arr, N):
		ans = []
		mp = {}
		for i in Arr:
			if i not in mp.keys():
				mp[i] = 1
			else:
				mp[i] += 1
		for i in mp.keys():
			if mp[i] & 1 == 1:
				ans.append(i)
		ans.sort(reverse=True)
		return ans


class Solution:

	def twoOddNum(self, Arr, N):
		dic = {}
		for i in Arr:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		b = []
		for i in dic:
			if dic[i] % 2 != 0:
				b.append(i)
		b.sort()
		b = list(reversed(b))
		return b


class Solution:

	def twoOddNum(self, Arr, N):
		xor = Arr[0]
		for i in range(1, N):
			xor ^= Arr[i]
		set_bit = xor & ~xor + 1
		(a, b) = (0, 0)
		for i in range(N):
			if set_bit & Arr[i]:
				b = b ^ Arr[i]
			else:
				a = a ^ Arr[i]
		return [a, b] if a > b else [b, a]


class Solution:

	def twoOddNum(self, A, N):
		xor = 0
		for i in range(0, N):
			xor ^= A[i]
		rmsb = xor & ~(xor - 1)
		x = 0
		y = 0
		for i in range(0, N):
			if rmsb & A[i] == 0:
				x = x ^ A[i]
			else:
				y = y ^ A[i]
		if x > y:
			return [x, y]
		else:
			return [y, x]


class Solution:

	def twoOddNum(self, arr, n):
		xor_all = arr[0]
		for i in range(1, n):
			xor_all ^= arr[i]
		set_bit = xor_all & -xor_all
		(x, y) = (0, 0)
		for i in range(n):
			if arr[i] & set_bit:
				x ^= arr[i]
			else:
				y ^= arr[i]
		ans = []
		if x >= y:
			ans.append(x)
			ans.append(y)
		else:
			ans.append(y)
			ans.append(x)
		return ans


class Solution:

	def twoOddNum(self, arr, N):
		set_no_bit = 0
		xor2 = arr[0]
		x = 0
		y = 0
		for i in range(1, N):
			xor2 = xor2 ^ arr[i]
		set_no_bit = xor2 & ~(xor2 - 1)
		for i in range(0, N):
			if arr[i] & set_no_bit:
				x = x ^ arr[i]
			else:
				y = y ^ arr[i]
		return sorted([x, y], reverse=True)


class Solution:

	def twoOddNum(self, Arr, N):
		Arr.sort()
		ans = []
		i = 0
		while i < N - 1:
			if Arr[i] ^ Arr[i + 1]:
				ans.append(Arr[i])
				i += 1
			else:
				i += 2
		if len(ans) != 2:
			ans.append(Arr[-1])
		return sorted(ans, reverse=True)


class Solution:

	def twoOddNum(self, Arr, N):
		ans = []
		s = 0
		for i in range(N):
			s = s ^ Arr[i]
		x = y = 0
		setbit = s & ~(s - 1)
		for i in Arr:
			if i & setbit != 0:
				x = x ^ i
			else:
				y = y ^ i
		ans.append(max(x, y))
		ans.append(min(x, y))
		return ans


class Solution:

	def twoOddNum(self, Arr, N):
		x = r1 = r2 = 0
		for i in range(N):
			x = x ^ Arr[i]
		s = x & ~(x - 1)
		for i in range(N):
			if Arr[i] & s != 0:
				r1 = r1 ^ Arr[i]
			else:
				r2 = r2 ^ Arr[i]
		if r1 > r2:
			return (r1, r2)
		return (r2, r1)


class Solution:

	def twoOddNum(self, Arr, N):

		def check_for_ith(x):
			n = 1 << x
			(one, two) = (0, 0)
			for i in Arr:
				if i & n:
					one ^= i
				else:
					two ^= i
			return [one, two] if one > two else [two, one]
		x = Arr[0]
		for i in Arr[1:]:
			x ^= i
		c = 0
		while x:
			r = x % 2
			if r == 1:
				return check_for_ith(c)
			c += 1
			x //= 2


class Solution:

	def twoOddNum(self, Arr, N):
		res = 0
		lis = []
		res1 = 0
		for i in Arr:
			res = res ^ i
		sn = res & ~(res - 1)
		res2 = 0
		for i in Arr:
			if sn & i != 0:
				res2 = res2 ^ i
			else:
				res1 = res1 ^ i
		lis.append(res2)
		lis.append(res1)
		lis.sort(reverse=True)
		return lis


from math import *

class Solution:

	def twoOddNum(self, Arr, N):
		xs = 0
		for x in Arr:
			xs = xs ^ x
		p = 0
		mk = 0
		while p <= floor(log(xs, 2)):
			if xs >> p & 1:
				mk = p
				break
			p += 1
		a = 0
		b = 0
		for x in Arr:
			if x >> mk & 1:
				a = a ^ x
			else:
				b = b ^ x
		return [max(a, b), min(a, b)]


class Solution:

	def twoOddNum(self, nums, n):
		xor = 0
		for i in nums:
			xor = xor ^ i
		cnt = 0
		while xor:
			if xor & 1 == 1:
				break
			cnt += 1
			xor = xor >> 1
		xor1 = 0
		xor2 = 0
		mask = 1 << cnt
		for i in nums:
			if i & mask != 0:
				xor1 = xor1 ^ i
			else:
				xor2 = xor2 ^ i
		return (xor1, xor2) if xor1 > xor2 else (xor2, xor1)


def posOfRightMostDiffBit(n):
	if n == 0:
		return 0
	k = 0
	while n:
		if n >> k & 1:
			return k
		k += 1

class Solution:

	def twoOddNum(self, Arr, N):
		arr = Arr
		res = [0] * 2
		xor = 0
		for i in arr:
			xor = i ^ xor
		setbit = posOfRightMostDiffBit(xor)
		arr1 = xor
		arr2 = xor
		for i in arr:
			if i >> setbit & 1 == 1:
				arr1 = arr1 ^ i
			elif i >> setbit & 1 == 0:
				arr2 = arr2 ^ i
		res[0] = arr2
		res[1] = arr1
		res.sort(reverse=True)
		return res


class Solution:

	def twoOddNum(self, Arr, N):
		a = []
		xor = 0
		for num in Arr:
			xor ^= num
		rightmost_set_bit = xor & ~(xor - 1)
		x = y = 0
		for num in Arr:
			if num & rightmost_set_bit:
				x ^= num
			else:
				y ^= num
		a.append(max(x, y))
		a.append(min(x, y))
		return a


class Solution:

	def twoOddNum(self, arr, n):
		ab = 0
		a = 0
		b = 0
		for x in arr:
			ab = ab ^ x
		bit = ab & -ab
		for x in arr:
			if x & bit:
				a = a ^ x
			else:
				b = b ^ x
		return (max(a, b), min(a, b))


class Solution:

	def twoOddNum(self, Arr, N):
		l = []
		dic = {}
		for i in Arr:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		for (i, j) in dic.items():
			if j % 2 != 0:
				l.append(i)
		return sorted(l, reverse=True)


class Solution:

	def twoOddNum(self, Arr, N):
		l = []
		dict = {}
		for i in Arr:
			dict[i] = dict.get(i, 0) + 1
		for (i, j) in dict.items():
			if j % 2 != 0:
				l.append(i)
		l.sort(reverse=True)
		return l


class Solution:

	def twoOddNum(self, Arr, N):
		d = {}
		for i in Arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		b = []
		for (k, v) in d.items():
			if v % 2 != 0:
				b.append(k)
		c = sorted(b)
		if b == c:
			return c[::-1]
		else:
			return b


class Solution:

	def twoOddNum(self, arr, N):
		xor = 0
		for x in arr:
			xor ^= x
		i = 0
		while not xor & 1:
			i += 1
			xor >>= 1
		numbers = [0, 0]
		for x in arr:
			numbers[x >> i & 1] ^= x
		return sorted(numbers, reverse=True)


class Solution:

	def twoOddNum(self, Arr, N):
		res = 0
		for i in Arr:
			res ^= i
		pos = 0
		while 1:
			if res & 1 << pos:
				break
			pos += 1
		x = 0
		y = 0
		for i in Arr:
			if i & 1 << pos:
				x ^= i
			else:
				y ^= i
		if x > y:
			return [x, y]
		else:
			return [y, x]


class Solution:

	def twoOddNum(self, Arr, N):
		l = []
		lst = Arr
		xor_result = 0
		for num in lst:
			xor_result ^= num
		rightmost_set_bit = xor_result & -xor_result
		num1 = 0
		num2 = 0
		for num in lst:
			if num & rightmost_set_bit:
				num1 ^= num
			else:
				num2 ^= num
		l.append(num1)
		l.append(num2)
		l.sort(reverse=True)
		return l


from collections import Counter

class Solution:

	def twoOddNum(self, Arr, N):
		arr1 = Counter(Arr)
		ans = [i for i in arr1 if arr1[i] % 2 != 0]
		return sorted(ans, reverse=True)
		return arr1[::-1]


class Solution:

	def twoOddNum(self, Arr, N):
		a = []
		s = set()
		for i in Arr:
			if i in s:
				s.remove(i)
			else:
				s.add(i)
		return sorted(list(s), reverse=True)


class Solution:

	def twoOddNum(self, Arr, N):
		axb = 0
		for item in Arr:
			axb = axb ^ item
		k = 0
		while axb & 1 << k == 0:
			k += 1
		a = 0
		b = 0
		for item in Arr:
			if item & 1 << k == 0:
				a = a ^ item
			else:
				b = b ^ item
		if a < b:
			return (b, a)
		else:
			return (a, b)


class Solution:

	def twoOddNum(self, Arr, N):
		l = []
		k = {}
		for i in range(N):
			if Arr[i] not in k:
				k[Arr[i]] = 1
			else:
				k[Arr[i]] += 1
		for i in k:
			if k[i] & 1:
				l.append(i)
		l.sort()
		return l[::-1]


class Solution:

	def xorr(self, arr):
		ans = 0
		for i in arr:
			ans ^= i
		return ans

	def twoOddNum(self, Arr, N):
		res = self.xorr(Arr)
		res1 = res
		count = 0
		while res1 > 0:
			if res1 & 1:
				break
			else:
				res1 >>= 1
				count += 1
		bitc = 1 << count
		arr2 = []
		for i in Arr:
			if i & bitc:
				arr2.append(i)
		a = self.xorr(arr2)
		b = res ^ a
		return [max(a, b), min(a, b)]


class Solution:

	def twoOddNum(self, nums, N):
		nums.sort()
		z = 0
		k = []
		n = len(nums)
		for i in range(n - 1):
			z = z ^ nums[i]
			if z == nums[i] and nums[i] != nums[i + 1]:
				k.append(nums[i])
				z = 0
		if nums[-1] != nums[-2]:
			k.append(nums[-1])
		k.reverse()
		return k


class Solution:

	def twoOddNum(self, arr, N):
		x = 0
		l = []
		arr.sort()
		for i in range(N - 1):
			x = x ^ arr[i]
			if x == arr[i] and arr[i] != arr[i + 1]:
				l.append(x)
				x = 0
		if arr[-2] != arr[-1]:
			l.append(arr[-1])
		l.reverse()
		return l


class Solution:

	def twoOddNum(self, Arr, N):
		from collections import Counter
		d = Counter(Arr)
		l = []
		for i in d:
			if d[i] % 2 != 0:
				l.append(i)
		ans = sorted(l)
		res = ans[::-1]
		return res


class Solution:

	def twoOddNum(self, arr, n):
		x = 0
		for i in arr:
			x = x ^ i
		c = x & ~(x - 1)
		a = 0
		b = 0
		for i in range(n):
			if arr[i] & c != 0:
				a = a ^ arr[i]
			else:
				b = b ^ arr[i]
		return (max(a, b), min(a, b))


class Solution:

	def twoOddNum(self, Arr, N):
		xor = 0
		for l1 in Arr:
			xor ^= l1
		count = 0
		while xor:
			if xor & 1:
				break
			else:
				count += 1
				xor = xor >> 1
		set_bit_xor = 0
		unset_xor = 0
		for l2 in Arr:
			if l2 & 1 << count:
				set_bit_xor = set_bit_xor ^ l2
			else:
				unset_xor = unset_xor ^ l2
		ans = [set_bit_xor, unset_xor]
		ans.sort(reverse=True)
		return ans


class Solution:

	def twoOddNum(self, arr, N):
		n = 0
		for i in arr:
			n ^= i
		ans = 0
		while n:
			if n & 1:
				break
			else:
				ans += 1
			n >>= 1
		a = b = 0
		for i in arr:
			if i & 1 << ans:
				a ^= i
			else:
				b ^= i
		return [max(a, b), min(a, b)]


class Solution:

	def twoOddNum(self, Arr, N):
		xor = 0
		x = y = 0
		for num in Arr:
			xor = xor ^ num
		rsb = xor & ~(xor - 1)
		for num in Arr:
			if rsb & num:
				x = x ^ num
			else:
				y = y ^ num
		return [x, y] if x > y else [y, x]


class Solution:

	def twoOddNum(self, arr, N):
		c = dict()
		for k in arr:
			if str(k) not in c:
				c[str(k)] = 0
			c[str(k)] += 1
		l = []
		for (k, v) in c.items():
			if int(v) % 2 != 0:
				l.append(int(k))
		return [max(l), min(l)]


class Solution:

	def twoOddNum(self, Arr, N):
		x = 0
		for i in range(N):
			x = x ^ Arr[i]
		rem = 1 << 34
		while x & rem == 0:
			rem = rem >> 1
		y = 0
		for i in range(N):
			if rem & Arr[i]:
				y = y ^ Arr[i]
		return [y, x ^ y]


class Solution:

	def twoOddNum(self, Arr, N):
		count = {}
		ans = []
		for item in range(0, N):
			if Arr[item] not in count:
				count[Arr[item]] = 1
			else:
				count[Arr[item]] += 1
		for keys in count:
			if count[keys] % 2 != 0:
				ans.append(keys)
		ans.sort()
		ans.reverse()
		return ans


class Solution:

	def twoOddNum(self, Arr, N):
		XOR = Arr[0]
		ans = []
		for i in range(1, N):
			XOR = XOR ^ Arr[i]
		rightmost_diff_bit = XOR & ~(XOR - 1)
		x = 0
		y = 0
		for i in range(N):
			if Arr[i] & rightmost_diff_bit != 0:
				x = x ^ Arr[i]
			else:
				y = y ^ Arr[i]
		ans.append(max(x, y))
		ans.append(min(x, y))
		return ans


from collections import Counter

class Solution:

	def twoOddNum(self, Arr, N):
		c = Counter(Arr)
		l = [i for i in c if c[i] % 2 != 0]
		return sorted(l, reverse=True)


class Solution:

	def twoOddNum(self, arr, n):
		xor = 0
		ans = []
		for i in range(n):
			xor = xor ^ arr[i]
		count = 0
		while xor:
			if xor & 1:
				break
			count += 1
			xor >>= 1
		xor1 = 0
		xor2 = 0
		for i in range(n):
			if arr[i] & 1 << count:
				xor1 ^= arr[i]
			else:
				xor2 ^= arr[i]
		ans.append(xor1)
		ans.append(xor2)
		ans.sort()
		return ans[::-1]


class Solution:

	def twoOddNum(self, Arr, N):
		z = 0
		for e in Arr:
			z ^= e
		rmsbm = z & -z
		(x, y) = (0, 0)
		for e in Arr:
			if e & rmsbm == 0:
				x ^= e
			else:
				y ^= e
		res = [x, y]
		res.sort(reverse=True)
		return res


class Solution:

	def twoOddNum(self, Arr, N):
		xor = x = y = 0
		for num in Arr:
			xor ^= num
		rbit = xor & -xor
		for num in Arr:
			if num & rbit:
				x ^= num
			else:
				y ^= num
		return [max(x, y), min(x, y)]


from collections import Counter

class Solution:

	def twoOddNum(self, Arr, N):
		d = Counter(Arr)
		ans = []
		for (k, v) in d.items():
			if v % 2 != 0:
				ans.append(k)
		ans.sort()
		return list(reversed(ans))


from functools import reduce

class Solution:

	def twoOddNum(self, Arr, N):
		xor = reduce(lambda x, y: x ^ y, Arr)
		s = xor & ~(xor - 1)
		a = b = 0
		for i in range(N):
			if s & Arr[i]:
				a ^= Arr[i]
			else:
				b ^= Arr[i]
		if a < b:
			(a, b) = (b, a)
		return [a, b]


class Solution:

	def twoOddNum(self, Arr, N):
		d = {}
		for i in Arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		ans = []
		for (i, j) in d.items():
			if j % 2 != 0:
				ans.append(i)
		ans.sort(reverse=True)
		return ans


class Solution:

	def twoOddNum(self, Arr, N):
		(ans, ans1, ans2) = (0, 0, 0)
		for x in Arr:
			ans = ans ^ x
		singleBit = ans & ~(ans - 1)
		for x in Arr:
			if singleBit & x != 0:
				ans1 = ans1 ^ x
			else:
				ans2 = ans2 ^ x
		return [max(ans1, ans2), min(ans2, ans1)]