3 ms·
First thing that came to mind for me (just assuming there was needed a practical way to do it) was the following (translated into Python): # associative arra
by thorax 18y ago
First thing that came to mind for me (just assuming there was needed a practical way to do it) was the following (translated into Python):
# associative array / dict / hash
store = {}
for elem in inputlist:
if elem in store:
del store[elem]
else:
store[elem] = True
# return the only key left
return store.keys()[0]
Now that I've looked at the post, the XOR approach is quite efficient and a more fun answer.