Created
May 6, 2019 17:31
-
-
Save gcasa/5f98956abe27b1aa3b8b5b2396aa022f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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