Skip to content

Instantly share code, notes, and snippets.

@agush22
Created February 20, 2018 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agush22/7b7ef8199b69d8ab232a838826b74888 to your computer and use it in GitHub Desktop.
Save agush22/7b7ef8199b69d8ab232a838826b74888 to your computer and use it in GitHub Desktop.
#First submission
def missingNumbersOne(arr, brr)
# Complete this function
result = []
arr.each do |x|
brr.delete_at(brr.find_index(x))
end
brr.sort.uniq
end
#Second submission
def missingNumbersTwo(arr, brr)
sums = Array.new(100, 0)
min = brr.min
arr.each do |x|
sums[x-min] -= 1
end
brr.each do |x|
sums[x-min] += 1
end
results =[]
sums.each_with_index do | x, i |
results << i+min if x > 0
end
results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment