Created
July 4, 2019 02:37
-
-
Save muzea/a50a68397bb6936cb48d7e13d9a69f60 to your computer and use it in GitHub Desktop.
Single Number II
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int singleNumber(vector<int>& nums) { | |
auto it = nums.begin(),end = nums.end(); | |
int o = 0,t = 0; | |
while(it != end){ | |
int oo = o; | |
o = (o^(*it))&(~(t&*it)); | |
t = (~(t&(*it))) & (oo & (*it) | t); | |
++it; | |
} | |
return o; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment