1、采用异或的方法实现,代码非常简单,详细如下:classSolution:defsingleNumber(self,nums:List[int])->int:res=0foriinnums:res^=ireturnres