Super short simple Python Solution || Dictionaries and Math.factorial
Intuition\n Describe your first thoughts on how to solve this problem. \nThe idea is very simple. Total count of anagrams for each word is\n(factorial of length
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe idea is very simple. Total count of anagrams for each word is\n(factorial of length of word) divided by factorial of duplicates.\n\nEg : aabbc -  5!/(2! * 2!)\n\n# Code\n```\nmod = 10**9+7\n\nclass Solution:\n    def countAnagrams(self, s: str) -> int:\n\n        l = s.split()\n        ans = 1\n\n        for i in l:\n            d = {}\n        # counting frequencies of word i in dictionary d\n            for j in i:\n                if(d.get(j)):\n                    d[j] += 1\n                else:\n                    d[j] = 1  \n            \n            duplicates = 1\n            for j in d.values():\n                duplicates *= math.factorial(j)\n            curr = math.factorial(len(i))//duplicates\n\n            ans *= curr\n            ans = ans%mod\n\n        return ans        \n        \n        \n```
['Python3']