We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Lonely Integer
Lonely Integer
Sort by
recency
|
559 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the vidéo explanation here : https://youtu.be/E4PVCUOdeXM
Two solutions in kotlin one using a set and the other using xor
XOR:
Set:
python 3
def lonelyinteger(a): # Write your code here return [x for x in a if a.count(x) == 1][0]
An one-liner in Python:
return 2*sum(set(a))-sum(a)
`