Skip to content

Instantly share code, notes, and snippets.

@rafaltrojanowski
Last active November 26, 2017 09:27
Show Gist options
  • Save rafaltrojanowski/c88cbcbe97ce877a84072bae0f734a73 to your computer and use it in GitHub Desktop.
Save rafaltrojanowski/c88cbcbe97ce877a84072bae0f734a73 to your computer and use it in GitHub Desktop.
def solution(a)
hash = {}
a.each do |element|
if hash[element].nil?
hash[element] = 1
else
hash[element] += 1
end
end
hash.select { |k, v| v % 2 == 1 }.keys.first
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment