You are viewing a single comment's thread. Return to all comments →
subtract takes any iterable, so you can just do:
subtract
from collections import Counter def number_needed(a, b): ct = Counter(a) ct.subtract(b) return sum(abs(i) for i in ct.values())
Saves yourself from creating another Counter. Fantastic solution though!
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
subtract
takes any iterable, so you can just do:Saves yourself from creating another Counter. Fantastic solution though!