From 7f6b015a3bd847d2c1cb4f7e34daa6c766787706 Mon Sep 17 00:00:00 2001 From: Jessica Kwok <60627484+jsca-kwok@users.noreply.github.com> Date: Mon, 17 May 2021 09:32:35 -0700 Subject: [PATCH] Update data_structures/hash_table/uncommon_words.rb Co-authored-by: Vitor Oliveira --- data_structures/hash_table/uncommon_words.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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"]