// although two passes, time is still O(n),

// better than sort which time is O(nlogn)

int size = A.size();

if (size == 0) return 0;

unordered_map<int, int> hash;

for (int i = 0; i < size; i++) {

if ( hash[A[i]] == 0) {

hash[A[i]]++;

} else {

hash[A[i]]--;

}

}

for (int i = 0; i < size; i++) {

if ( hash[A[i]] == 1) {

return A[i];

}

}