Skip to content

Instantly share code, notes, and snippets.

@lelandjansen
Last active June 26, 2021 09:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lelandjansen/40aba775f84947116187 to your computer and use it in GitHub Desktop.
Save lelandjansen/40aba775f84947116187 to your computer and use it in GitHub Desktop.
Returns the value of the unpaired element in an array
int oddOccurrencesInArray(int A[], int N) {
int value = 0;
for (int i = 0; i < N; ++i) value ^= A[i];
return value;
}
// Source: https://codility.com/programmers/task/odd_occurrences_in_array/
// Score: 100%
// That's all folks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment