You are viewing a single comment's thread. Return to all comments →
Python:
def makeAnagram(a, b): difference = {} only_b = 0 for char in a: difference[char] = difference.get(char, 0) + 1 for char in b: if char in difference and difference[char] > 0: difference[char] -= 1 else: only_b+=1 totalElementsA = sum(difference.values()) return abs(totalElementsA + only_b)
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 →
Python: