Skip to content

Commit 0f0e37c

Browse files
authored
Create 137. Single Number II.cpp
1 parent a33354f commit 0f0e37c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

137. Single Number II.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int singleNumber(vector<int>& nums) {
4+
int check, count, ans = 0;
5+
for(int i=0; i<=31; i++){
6+
check = 1<<i, count=0;
7+
for(auto n : nums) if(n & check) count++;
8+
if(count%3) ans |= check;
9+
}
10+
return ans;
11+
}
12+
};

0 commit comments

Comments
 (0)