只出现一次的数字

题目链接

题目思路

a^a=0
a^0=a

go解题思路

1
2
3
4
5
6
7
8
func singleNumber(nums []int) int {
a := 0
for _, v := range nums {
a ^= v
}
return a
}