Skip to content

Instantly share code, notes, and snippets.

@gbazilio
Last active January 17, 2017 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbazilio/212c36379c6c33c865898205d922287e to your computer and use it in GitHub Desktop.
Save gbazilio/212c36379c6c33c865898205d922287e to your computer and use it in GitHub Desktop.
Codility - Odd occurrences
def solution(A):
A = sorted(A)
for index in range(0, len(A), 2):
next_index = index+1
if next_index >= len(A) or A[index] != A[index+1]:
return A[index]
def solution(A):
result = A[0]
for index in range(1, len(A)):
result = result ^ A[index]
return result
def solution(A):
return reduce(lambda x, y: x^y, A)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment