class Solution:
‘’’
参数n:输入的待查数组
返回值:内容没有重复的两个值的列表
&表示按位与
^表示按位异或
<<表示左移位
‘’’
def repetition(self,n):
x=[0,0]
for i in n:
x[0]=x[0]^i
a=1
while a & x[0] != a:
a=a<<1
for i in n:
if i & a==a:
x[1]=x[1]^i
x[0]=x[0] ^ x[1]
return x
#主函数
if name == ‘main’:
n=[1,2,2,5,1,8,6,8]
solution= Solution()
print("输入数组:",n)
print("输出没有重复数字的数组:", solution.repetition(n))
![在这里插入图片描述](https://img-blog.csdnimg.cn/8f85ad69eaaf415e8394478bfe6192eb.jpg?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5rSq6I2S5a6H5a6ZcHk=,size_20,color_FFFFFF,t_70,g_se,x_16)