Update data_structures/hash_table/uncommon_words.rb

Co-authored-by: Vitor Oliveira <vbrazo@gmail.com>
This commit is contained in:
Jessica Kwok 2021-05-17 09:32:35 -07:00 committed by GitHub
parent a591b2fd56
commit 7f6b015a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,11 +29,7 @@ def find_uncommon_words(strA, strB)
result = [] result = []
array.each do |word| array.each do |word|
if hash[word] hash[word] += 1
hash[word] += 1
else
hash[word] = 1
end
end end
hash.each do |k, v| hash.each do |k, v|
@ -49,4 +45,4 @@ puts find_uncommon_words("this apple is sweet", "this apple is sour")
# => ["sweet", "sour"] # => ["sweet", "sour"]
puts find_uncommon_words("apple apple", "banana") puts find_uncommon_words("apple apple", "banana")
# => ["banana"] # => ["banana"]