public int singleNumber(int[] A) {
        int res = 0;
        for(int i = 0; i < 32; ++i){
            int bit = 1 << i;
            int count = 0;
            for(int a : A){
                count += (a&bit) >> i;
            }

            res |= (count%3) << i;
        }
        return res;
    }