feiqiangs的学习心得

# 260. Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.

For example:

Given nums = [1, 2, 1, 3, 2, 5], return [3, 5].

Note:

1. The order of the result is not important. So in the above example, [5, 3] is also correct.
2. Your algorithm should run in linear runtime complexity. Could you implement it using only constant space complexity?

class Solution {
public:
vector<int> singleNumber(vector<int>& nums) {
int oxr =0;
for(int i =0;i<nums.size();i++) oxr^=nums[i];
int mark = oxr&(-oxr);
int a =0,b=0;
for(int i =0;i<nums.size();i++){
if(nums[i]&mark){
a^=nums[i];
}else{
b^=nums[i];
}
}
return vector<int>{a,b};

}
};

#### [leetcode] 260.Single Number III

2015-08-17 17:42:59

#### [LeetCode 260] Single Number III

2015-09-13 04:22:02

#### 260. Single Number III [medium] (Python)

2016-07-30 10:58:25

#### LeetCode（260） Single Number III

2015-12-02 14:41:41

#### LeetCode 260 Single Number III（只出现一次的数字 III）（*）

2016-02-18 15:06:24

#### .260. Single Number III

2016-08-30 16:01:34

#### LeetCode Single Number III 异或＋补码

2015-11-15 22:23:51

#### 260. Single Number III LeetCode

2016-02-13 17:07:42

#### leetcode 260. Single Number III

2016-05-24 16:23:38

#### 260. Single Number III [leetcode]

2017-08-10 00:33:18