-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxor_operation.py
More file actions
37 lines (33 loc) · 842 Bytes
/
xor_operation.py
File metadata and controls
37 lines (33 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def solve(arr):
dict={}
lis=[]
new=[]
for i in range(len(arr)):
if dict.get(arr[i]):
d=dict[arr[i]]
dict[arr[i]]=d+1
else:
dict[arr[i]]=1
lis.append(arr[i])
for i in range(len(lis)):
temp_res=-1
for j in range(i+1,len(lis)):
temp_res=lis[i]^lis[j]
if dict[lis[i+1]]%2!=0:
pass
else:
temp_res=0
if dict[lis[i]]%2!=0:
pass
else:
temp_res=0
new.append(temp_res)
res=0
print(new)
for i in range(len(new)):
res=res^new[i]
return res
if __name__ == "__main__":
tb=int(input())
arr = list(map(int,input().split()))
print(solve(arr))