You are viewing a single comment's thread. Return to all comments →
def checkMagazine(magazine, note): n = len(note) can_replicate = "Yes" magazine_words = {} for word in magazine: magazine_words.setdefault(word, 0) magazine_words[word] += 1 for word in range(n): found = magazine_words.get(note[word]) if not found or magazine_words.get(note[word]) <= 0: can_replicate = "No" break magazine_words[note[word]] -= 1 print(can_replicate)
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 →