class Solution {
public:
int num[32];
void fun(int a){
for(int i=0;i<32;i++){
if(a&(1<<i))
num[i]++;
}
}
int singleNumber(int A[], int n) {
// Note: The Solution object is instantiated only once and is reused by each test case.
memset(num,0,sizeof(num));
for(int i=0;i<n;i++)
fun(A[i]);
int ans = 0;
for(int i=0;i<32;i++){
if(num[i]%3){
ans+=(1<<i);
}
}
return ans;
}
};
public:
int num[32];
void fun(int a){
for(int i=0;i<32;i++){
if(a&(1<<i))
num[i]++;
}
}
int singleNumber(int A[], int n) {
// Note: The Solution object is instantiated only once and is reused by each test case.
memset(num,0,sizeof(num));
for(int i=0;i<n;i++)
fun(A[i]);
int ans = 0;
for(int i=0;i<32;i++){
if(num[i]%3){
ans+=(1<<i);
}
}
return ans;
}
};