Single Number II
Code:
class Solution { public: int singleNumber(int A[], int n) { // Note: The Solution object is instantiated only once and is reused by each test case. int res = 0; int bit,i,j; for(i=0;i<32;i++){ for(j=0, bit=0;j<n;j++){ if((A[j]>>i)&1==1) bit = (bit+1)%3; } if(bit!=0) bit = 1; res = res | (bit<<i); } return res; } };