c++ solution
\nclass Solution {\npublic:\n    using ll =long long;\n    ll mod=1e9+7;\n    ll fact[100005];\n    ll power(ll a,ll b)\n    {\n        ll res=1;\n        while
```\nclass Solution {\npublic:\n    using ll =long long;\n    ll mod=1e9+7;\n    ll fact[100005];\n    ll power(ll a,ll b)\n    {\n        ll res=1;\n        while(b)\n        {\n            if(b&1)\n            {\n                res=(res*a)%mod;\n            }\n            a=(a*a)%mod;\n            b/=2;\n        }\n        return res;\n    }\n    ll cal(vector<int>&dp)\n    {\n        ll sum=0;\n        for(int i=0;i<26;i++)\n        {\n            sum+=dp[i];\n        }\n        ll ans=fact[sum]; // total permutation \n        for(int i=0;i<26;i++)\n        {\n            ans*=(power(fact[dp[i]],mod-2)); // remove duplicate\n            ans%=mod;\n        }\n        /*\n        formula\n          n!/(a!* b! * c! )\n          where a b c are freq of char\n        */\n        return ans;\n    }\n    int countAnagrams(string s) \n    {\n        fact[0]=1;\n        for(int i=1;i<100005;i++)\n        {\n            fact[i]=(i*fact[i-1])%mod;\n        }\n        int n=s.size();\n        vector<int>dp(26,0);\n        ll ans=1;\n        for(int i=0;i<n;i++)\n        {\n            if(s[i]==\' \')\n            {\n                ll value=cal(dp);\n                ans*=value;\n                ans%=mod;\n                dp=vector<int>(26,0);\n            }\n            else\n            {\n                dp[s[i]-\'a\']++;\n            }\n        }\n        ll value=cal(dp);\n        ans*=value;\n        ans%=mod;\n        return (int)ans;\n    }\n};\n```
['Math', 'C', 'C++']