. - 力扣(LeetCode)

 
from typing import List
 
# 排序后做,题意说最多出现2次。前后做比对,相同则做异或操作即可
class Solution:
	def duplicateNumbersXOR(self, nums: List[int]) -> int:
		result = 0
		nums.sort()
		for i in range(len(nums) - 1):
			if nums[i] == nums[i + 1]:
				result ^= nums[i]
		return result