Strings: Making Anagrams

  • + 0 comments

    Python Solution using counter

    from collections import Counter
    
    def makeAnagram(a, b):
        # Write your code here
        a_dict = Counter(a)
        b_dict = Counter(b)
        
        difference_1 = a_dict - b_dict
        difference_2 = b_dict - a_dict
        
        total_removal = sum(difference_1.values()) + sum(difference_2.values())
        
        return total_removal