You are viewing a single comment's thread. Return to all comments →
It's rare to see, but Python has its own XOR operator!
Just be aware that the following code does not works if the array has an element with more than two occurrences:
def lonelyinteger(a): unique = 0 for num in a: unique ^= num return unique
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all comments →
It's rare to see, but Python has its own XOR operator!
Just be aware that the following code does not works if the array has an element with more than two occurrences: