Skip to content

Commit 73f7b9d

Browse files
committed
137
1 parent c1a1c8e commit 73f7b9d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

137.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public:
3+
int singleNumber(vector<int>& nums) {
4+
5+
long long int result=0;
6+
int n=nums.size();
7+
int bits[32]= {0};
8+
9+
for(int i=0;i<32;i++){
10+
for(int n:nums){
11+
12+
bits[i]+= (n>>i) & 1;
13+
bits[i]=bits[i]%3;
14+
15+
16+
}
17+
}
18+
19+
for(int i=0;i<32;i++){
20+
result=result+pow(2,i)*bits[i];
21+
// cout<<result<<endl;
22+
}
23+
24+
return result;
25+
}
26+
};

0 commit comments

Comments
 (0)