My solution to this problem. Simple and easy to understand


#1
public class Solution {
// DO NOT MODIFY THE LIST. IT IS READ ONLY
public int singleNumber(final List<Integer> A) {
    int ans = 0;
    int c=0;
    for(int i=0;i<32;i++)
    {
        c = bits(A,i);
        if(c % 3 != 0)
        {
            ans = ans + (1<<i);
        }
    }
    return ans;
    
}

int bits(final List<Integer>A,int i)
{
    int count = 0;
    int size = A.size();
    for(int j=0;j<size;j++)
    {
        if(checkBit(A.get(j),i))
        {
            count++;
        }
    }
    return count;
}
public boolean checkBit(int n,int i)
{
    boolean ans = (((n>>i)&1) == 1);
    return ans;
}

}