We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defmakingAnagrams(s1,s2):# Count frequency of chars in both stringsfreq_s1=Counter(s1)freq_s2=Counter(s2)# Calculate the total number of chars that need to be deleteddeletion_count=0forcharinset(s1+s2):deletion_count+=abs(freq_s1[char]-freq_s2[char])returndeletion_count
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Making Anagrams
You are viewing a single comment's thread. Return to all comments →