public int singleNumber(int[] A) {
        int[] result = new int[32];
        for (int i = 0; i < A.length; i++) {
            int crt = A[i];
            for (int j = 0; j < 32; j++) {
                if ((crt & (1<<j)) != 0) {
                    result[j]++;
                }
            }
        }
        
        int num = 0;
        for (int i = 0; i < 32; i++) {
            result[i] %= 3;
            num += (result[i]<<i);
        }
        
        return num;
    }