Most Basic approach for beginners-C++(Beats -80%)
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```\nclass Solution {\n    int mod = 1e9+7;\n    long long int helper(long long a, long long b)\n    {\n        long long res=1;\n        while(b>0)\n        {\n            if(b%2==1)\n            {\n                res = (res*a)%mod;\n            }\n            a = (a*a)%mod;\n            b=b/2;\n        }\n        return res;\n    }\npublic:\n    int countAnagrams(string s) {\n        int mod = 1e9+7;\n        int n=s.length();\n        vector<long long int> fac(n+1,1);\n        vector<long long int> inv(n+1,1);\n        for(int i=1; i<=n; i++)\n        {\n            fac[i] = (fac[i-1]*(i))%mod;\n        }\n        inv[n] = helper(fac[n], mod-2);\n        inv[n] %= mod;\n        for(int i=n-1; i>=0; i--)\n        {\n            inv[i] = inv[i+1]*(i+1)%mod;\n        }\n        long long int ans=1;\n        int idx=0;\n        while(idx<n)\n        {\n            string res="";\n            vector<int> count(26, 0);\n            while(s[idx]!=\' \' and idx<n)\n            {\n                res+= s[idx];\n                count[s[idx]-\'a\']++;\n                idx++;\n            }\n            int len = res.length();\n            ans = (ans*fac[len])%mod;\n            for(int i=0; i<26; i++)\n            {\n                if(count[i]>0)\n                {\n                    ans = (ans*inv[count[i]])%mod;\n                }\n            }\n            idx++;\n        }\n        return ans%mod;\n    }\n};\n```
['C++']