You are viewing a single comment's thread. Return to all comments →
It seems like the following using dict is faster than Counter approach above.
Can someone confirm this ?
def number_needed(a, b): h = dict.fromkeys(a + b, 0) for c in a: h[c] += 1 for c in b: h[c] -= 1 return sum(abs(v) for v in h.values())
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 →
It seems like the following using dict is faster than Counter approach above.
Can someone confirm this ?