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.
Ah, thats simpler than mine using Counter and sets, but the same idea I guess.
fromcollectionsimportCounter# Complete the make_anagram function below.defmake_anagram(a,b):c1=Counter(a)s1=set(c1)c2=Counter(b)s2=set(c2)forc,ninc1.items():foriinrange(n-1):s1.add(c+str(i))forc,ninc2.items():foriinrange(n-1):s2.add(c+str(i))common=s1.intersection(s2)rem1=s1-commonrem2=s2-commonreturnlen(rem1)+len(rem2)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Ah, thats simpler than mine using Counter and sets, but the same idea I guess.