Skip to content

Instantly share code, notes, and snippets.

@creichert
Created November 16, 2017 17:30
Show Gist options
  • Save creichert/11d9db86368427225cd300260312fd74 to your computer and use it in GitHub Desktop.
Save creichert/11d9db86368427225cd300260312fd74 to your computer and use it in GitHub Desktop.
Find number in a list that occurs an odd number of times
import Data.List
import Data.Bits
-- > 1
main = print $ foldl xor 0 [1,1,2,2,3,3,4,4,5,5,6,6,7,7,1]
@creichert
Copy link
Author

"You have a very large array of integers. One of the integers appears an odd number of times, and all the rest appear an even number of times. Write efficient code to find that integer with the odd count."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment