mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Update data_structures/hash_table/uncommon_words.rb
Co-authored-by: Vitor Oliveira <vbrazo@gmail.com>
This commit is contained in:
parent
a591b2fd56
commit
7f6b015a3b
1 changed files with 2 additions and 6 deletions
|
@ -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"]
|
||||||
|
|
Loading…
Reference in a new issue