Skip to content

Instantly share code, notes, and snippets.

@r-wheeler
Created October 30, 2015 17:44
Show Gist options
  • Save r-wheeler/09557cb72b4181638586 to your computer and use it in GitHub Desktop.
Save r-wheeler/09557cb72b4181638586 to your computer and use it in GitHub Desktop.
hackerrank anagram
from collections import Counter
def algo(a,b):
ca = Counter(a)
cb = Counter(b)
ct = Counter(a+b)
return sum(abs(ca[k] - cb[k]) for k in ct.keys())
a, b = raw_input(), raw_input()
print algo(a,b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment