You are viewing a single comment's thread. Return to all comments →
Also used collection's Counter. Did not know about the - operator, though. Learning new stuff every day. Cheers!
-
def ransom_note(magazine, ransom): if len(magazine) < len(ransom): return False magazine_counter = Counter(magazine) ransom_counter = Counter(ransom) for word, count in ransom_counter.items(): if word not in magazine_counter or magazine_counter.get(word) < count: return False return True
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
Also used collection's Counter.
Did not know about the
-
operator, though. Learning new stuff every day. Cheers!