Skip to content

Instantly share code, notes, and snippets.

@see-why
Created March 22, 2022 22:54
Show Gist options
  • Save see-why/41c6da085f92a058726d4185469f99a6 to your computer and use it in GitHub Desktop.
Save see-why/41c6da085f92a058726d4185469f99a6 to your computer and use it in GitHub Desktop.
Hackerrank anagram challenge solution
# https://www.hackerrank.com/challenges/anagram/problem?isFullScreen=true
def anagram(s):
# Write your code here
if len(s)%2: return -1
l = len(s)//2
a = collections.Counter(s[:l])
b = collections.Counter(s[l:])
return l-sum((a & b).values())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment