Skip to content

Instantly share code, notes, and snippets.

@gcasa
Created May 6, 2019 17:31
Show Gist options
  • Save gcasa/5f98956abe27b1aa3b8b5b2396aa022f to your computer and use it in GitHub Desktop.
Save gcasa/5f98956abe27b1aa3b8b5b2396aa022f to your computer and use it in GitHub Desktop.
# you can write to stdout for debugging purposes, e.g.
# puts "this is a debug message"
# this only gets 66% not sure what's wrong.
def solution(a)
# write your code in Ruby 2.2
result = 0
buckets = {}
index = 0
a.each do |num|
buckets[num] = Array.new if buckets[num].nil?
buckets[num].push index
index = index + 1
end
buckets.each do |k, v|
# puts "bucket = #{v}"
if v.length == 1
# puts "bucket = #{bucket}"
result = k
end
end
return result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment