Created
March 6, 2019 01:58
-
-
Save nathanworden/e76fa1fc097c8f5f0a9b359e529b1656 to your computer and use it in GitHub Desktop.
Ruby Meetup
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
ALPHA = ('a'..'z').to_a | |
def missing_alphabets(s) | |
alpha_hash = {} | |
ALPHA.each {|e| alpha_hash[e] = 0} | |
missing = "" | |
s.chars.each do |char| | |
alpha_hash[char] += 1 | |
end | |
num_alphabets = alpha_hash.values.max | |
alpha_hash.each do |key, value| | |
while value < num_alphabets | |
missing << key | |
value += 1 | |
end | |
end | |
missing | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment