You are viewing a single comment's thread. Return to all comments →
Python 3
import collections def anagram(s): length = len(s) if length%2: return -1 half = int(length//2) tally = collections.Counter(s[:half]) for i in s[half:]: tally[i] -= 1 total = [0,0] for count in tally.values(): if count >= 0: total[0] += count else: total[1] -= count return max(total)
Seems like cookies are disabled on this browser, please enable them to open this website
Anagram
You are viewing a single comment's thread. Return to all comments →
Python 3