C++ || TIME O(n),SPACE(n) || MULTIPLY PERMUTATION || SHORT & SWEET CODE
/\nlets a substring is aaabbbcc\nso ans for this \n          8!/(3!3!2!)\n/\n\nclass Solution {\npublic:\n    int getinverse(long long int a,int b,int c){\n    
/*\nlets a substring is aaabbbcc\nso ans for this \n          8!/(3!*3!*2!)\n*/\n````\nclass Solution {\npublic:\n    int getinverse(long long int a,int b,int c){\n        long long int ans = 1;\n        while(b){\n            if(b&1){\n                ans = (ans*a)%c;\n            }\n            a = (a*a)%c;\n            b >>= 1;\n        }\n        return ans;\n    }\n    int countAnagrams(string s) {\n        int mod = 1e9+7;\n        int n = s.length(),i;\n        vector<int> fact(n+10,1);\n        for(i = 2; i <= n+8; i++){\n            fact[i] = (fact[i-1]*1LL*i)%mod;//get factorial till s.length\n        }\n        long long int ans = 1,tmp;\n        vector<int> factinv(n+10,0);\n        for(int i = 0; i <= n+8; i++){\n            factinv[i] = getinverse(fact[i],mod-2,mod);//factorial inverse of eash number\n        }\n        vector<int> dp(26,0);\n        int k = 0;//k = length of substring\n        for(auto &i: s){\n            if(i==\' \'){//perform above mentioned approach\n                tmp = fact[k];//\n                for(auto &j: dp){\n                    tmp = (tmp*1LL*factinv[j])%mod;\n                }\n                ans = (ans*tmp)%mod;\n                fill(dp.begin(),dp.end(),0);\n                k = 0;\n            }else{\n                dp[i-\'a\']++;\n                k++;\n            }\n        }\n\t\t//for last substring\n        tmp = fact[k];\n        for(auto &j: dp){\n        tmp = (tmp*1LL*factinv[j])%mod;\n        }\n        ans = (ans*tmp)%mod;\n        return ans;\n    }\n};\n````
['Math', 'String', 'C', 'C++']