Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
描述
一组数,除了一个数外,其余数都出现 2 次,找出那个数
分析
使用异或的方式,A ^ A = 0
,A ^ A ^ B = B
代码
1 | public class Solution { |