This is an interview question.
Given an array of integers, find the single integer value in the array which occurs with even frequency. All integers will be
I guess we read the task improperly. It asks us "find the single integer value in the array which occurs with even frequency". So, assuming that there is exactly ONE even element, the solution is:
public static void main(String[] args) {
int[] array = { 2, 1, 2, 4, 4 };
int count = 0;
for (int i : array) {
count^=i;
}
System.out.println(count); // Prints 1
}