标签:ber 链接 题目 运算 pre ble 数字 amp number
题目链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-lcof/
class Solution {
public:
vector<int> singleNumbers(vector<int>& nums) {
int s = 0;
for(int num : nums)
s ^= num;
int k = s & (-s);
vector<int> rs(2, 0);
for(int num : nums)
{
if(num & k) rs[0] ^= num;
else rs[1] ^= num;
}
return rs;
}
};
【剑指offer】【位运算】56 - I. 数组中数字出现的次数
标签:ber 链接 题目 运算 pre ble 数字 amp number
原文地址:https://www.cnblogs.com/Trevo/p/12770576.html