• + 0 comments
    from collections import Counter
    
    def anagram(s):
        n = len(s)
        if n % 2 == 1:
            return -1  
        a = s[:n//2]
        b = s[n//2:]
        freq_a = Counter(a)
        freq_b = Counter(b)
        changes = 0
        for char in freq_a:
            if freq_a[char] > freq_b.get(char, 0):
                changes += freq_a[char] - freq_b.get(char, 0)
        return changes