Skip to content

Instantly share code, notes, and snippets.

@lion137
Created December 15, 2019 17:51
Show Gist options
  • Save lion137/37db480d8c291744a24d22d680553e91 to your computer and use it in GitHub Desktop.
Save lion137/37db480d8c291744a24d22d680553e91 to your computer and use it in GitHub Desktop.
xor to find unpaired
# python:
def find_unpaired(xs):
"""find unpaired element with array of 2n + 1 elements"""
for i in range(1, len(xs)):
xs[i] ^= xs[i - 1]
print(xs[len(xs) - 1])
# pseudocode:
fun findUnpaired(aList):
#N - length of input list
for i from 1 to N:
aList[i] ^= aList[i - 1]
print(aList[N - 1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment