Given a non-empty array of integers, every element appears twice except for one. Find that single one.
Solution: O(n)
Using bitwise xOr: x ^ x = 0, 0 ^ x = x
class Solution {
func singleNumber(_ nums: [Int]) -> Int {
return nums.reduce(0, ^)
}
}