You are viewing a single comment's thread. Return to all comments →
Clear Python solution
def makeAnagram(a, b): remove_count = 0 a_set = set(a) b_set = set(b) a_count_map = {el: a.count(el) for el in a_set} b_count_map = {el: b.count(el) for el in b_set} for el in a_set: if a_count_map.get(el, 0) > b_count_map.get(el, 0): remove_count += a_count_map.get(el, 0) - b_count_map.get(el, 0) for el in b_set: if b_count_map.get(el, 0) > a_count_map.get(el, 0): remove_count += b_count_map.get(el, 0) - a_count_map.get(el, 0) return remove_count
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Clear Python solution