Saturday, March 4, 2023
Given a non-empty array of integers nums
, every element appears twice except for one. Find that single one.
n
is a length of a number arrayfunc singleNumber(nums []int) int {
singleNumber := 0
for _, n := range nums {
singleNumber ^= n
}
return singleNumber
}