Skip to content

Instantly share code, notes, and snippets.

@imedadel
Created November 3, 2019 18:53
Show Gist options
  • Select an option

  • Save imedadel/2d4723ea3d2d556f8497ac7b52de26a0 to your computer and use it in GitHub Desktop.

Select an option

Save imedadel/2d4723ea3d2d556f8497ac7b52de26a0 to your computer and use it in GitHub Desktop.
from collections import Counter
def makeAnagram(a, b):
freqA = Counter(a)
freqB = Counter(b)
intersection = freqA & freqB
return sum(freqA.values()) + sum(freqB.values()) - sum(intersection.values()) * 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment