Skip to content

Instantly share code, notes, and snippets.

@see-why
Created March 23, 2022 22:08
Show Gist options
  • Save see-why/ae254e5923f71a2cdfb77257652506d1 to your computer and use it in GitHub Desktop.
Save see-why/ae254e5923f71a2cdfb77257652506d1 to your computer and use it in GitHub Desktop.
HackerRank Making Anagrams challenge solution
# https://www.hackerrank.com/challenges/making-anagrams/problem?isFullScreen=true
def makingAnagrams(s1, s2):
# Write your code here
a = collections.Counter(s1)
b = collections.Counter(s2)
sum_of_commons = sum((a & b).values())
return (len(s1)-sum_of_commons) + (len(s2)-sum_of_commons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment