C++ Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n    Calculate the number of permutations of each word,\n    Formula is: N! / (Ma! * Mb!
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n    Calculate the number of permutations of each word,\n    Formula is: N! / (Ma! * Mb! * ... * Mz!)\n    where N is the amount of letters in the word, and \n    Ma, Mb, ..., Mz are the occurrences of repeated letters in the word. \n    Each M equals the amount of times the letter appears in the word.\n    \n    Multiply number of permutations of each word.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(Nlog(mod))\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(N)\n\n# Code\n```\n#define ll long long\n#define mod 1000000007\nclass Solution {\npublic:\n    ll fact[100005];\n\n    void factorial(ll n) {\n        fact[0] = 1;\n        for(ll i=1; i<=n; i++) fact[i] = i * fact[i-1] % mod;\n    }\n\n    ll powmod(ll a, ll b) {\n        ll ans = 1;\n        while(b > 0) {\n            if(b & 1) ans = ans * a % mod;\n            a = a * a % mod;\n            b >>= 1;\n        }\n        return ans;\n    }\n\n    ll inv(ll x) {\n        return powmod(x, mod-2);\n    }\n    \n    int countAnagrams(string s) {\n        ll n = s.size();\n        factorial(n);\n        s.push_back(\' \');\n        unordered_map<char, ll> mp;\n        ll ans = 1, cnt = 0;\n        for(auto c: s) {\n            if(c == \' \') {\n                ll up = fact[cnt];\n                for(auto x: mp) {\n                    ll down = fact[x.second];\n                    up = up * inv(down) % mod;\n                }\n                ans = ans * up % mod;\n                mp.clear();\n                cnt = 0;\n            }\n            else {\n                mp[c]++;\n                cnt++;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']