diff --git a/data_structures/hash_table/uncommon_words.rb b/data_structures/hash_table/uncommon_words.rb index 9e17b61..ff0ace9 100644 --- a/data_structures/hash_table/uncommon_words.rb +++ b/data_structures/hash_table/uncommon_words.rb @@ -29,11 +29,7 @@ def find_uncommon_words(strA, strB) result = [] array.each do |word| - if hash[word] - hash[word] += 1 - else - hash[word] = 1 - end + hash[word] += 1 end hash.each do |k, v| @@ -49,4 +45,4 @@ puts find_uncommon_words("this apple is sweet", "this apple is sour") # => ["sweet", "sour"] puts find_uncommon_words("apple apple", "banana") -# => ["banana"] \ No newline at end of file +# => ["banana"]