21. 只出现一次的数字 发表于 2019-02-05 更新于 2025-04-02 分类于 programming 题目描述 解析 利用异或运算的性质 x ^ x = 0 x ^ 0 = x 对所有数字异或运算 $x_1$ ^ $x_2$ ^ …… ^ $x_n$ = 只出现过一次的数 程序123456int singleNumber(vector<int>& nums) { int res = 0; for(auto x : nums) res ^= x; return res;}