Easy Factorial Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    const int M = 1e9+7;\n\n    long long pow(long long a, long long b){\n        if(b == 0) return 1;\n\n        long long ret = pow(a, b/2);\n        ret = ret * ret;\n        ret %= M;\n        if(b % 2) ret = ret * a;\n        ret %= M;\n\n        return ret;\n    }\n    int div(long long p, long long q){\n        long long ret = p * pow(q, M-2);\n\n        return ret % M;\n    }\n    int countAnagrams(string s) {\n        int n = s.size();\n        // number of distince anagrams of s. \n        vector<string> v;\n\n        string str = "";\n        for(auto &c: s){\n            if(c == \' \'){\n                v.push_back(str);\n                str = "";\n            }\n            else str += c;\n        }\n        v.push_back(str);\n\n        int N = 1e5+10;\n        vector<long long> fac(N);\n        fac[0] = 1;\n        fac[1] = 1;\n        for(int i = 2; i < N; i++){\n            fac[i] = (fac[i-1] * i) % M;\n        }\n\n        long long ans = 1;\n        for(auto &word: v){\n            int siz = word.size();\n            map<char, int> mp;\n            for(auto &c: word) mp[c]++;\n            long long cnt = fac[siz];\n\n            for(auto it: mp){\n                cnt = div(cnt, fac[it.second]);\n            }\n\n            ans = (ans * cnt) % M;\n        }\n\n        return ans;\n    }\n};\n```
['Hash Table', 'Math', 'String', 'Combinatorics', 'Counting', 'C++']