原题链接
数组中所有元素的异或运算结果就是数组中只出现一次的数字。
const singleNumber = function(nums) { let ans = 0 for (const num of nums) { ans ^= num } return ans }