Created
October 3, 2019 14:33
-
-
Save chastep/80453c3bf551a8fadb19cdb73e30c9cc to your computer and use it in GitHub Desktop.
Hacker Rank Find Missing Numbers
This file contains 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
# https://www.hackerrank.com/challenges/missing-numbers/problem | |
def missingNumbers(arr, brr) | |
og_hash = brr.inject(Hash.new(0)) { |h,v| h[v] += 1; h } | |
missing_hash = arr.inject(Hash.new(0)) { |h,v| h[v] += 1; h } | |
og_hash.select { |k, v| missing_hash[k] < v || (v == 1 && !missing_hash[k]) }.keys.sort | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment