2 pointer + Rolling Hash
Code\n\nclass Solution {\npublic:\n    const int mod=1e9+7;\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        map<int,int> freq;\n
# Code\n```\nclass Solution {\npublic:\n    const int mod=1e9+7;\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        map<int,int> freq;\n        vector<int> count(26,0);\n        int l=0;\n        int ans=0;\n        int noOfLetter=0;\n        long hash_curr=0;\n        long pow=1;\n        for(int i=0;i<minSize-1;i++){\n            pow=(pow*53)%mod;\n        }\n        for(int r=0;r<s.size();r++){\n            count[s[r]-\'a\']++;\n            if(count[s[r]-\'a\']==1){\n                noOfLetter++;\n            }\n            if((r-l+1)>minSize){\n                hash_curr=((hash_curr-(s[l]-\'a\'+1)*pow)%mod +mod)%mod;\n                count[s[l]-\'a\']--;\n                if(count[s[l]-\'a\']==0){\n                   noOfLetter--; \n                }\n                l++;\n            }\n            hash_curr=((hash_curr*53)%mod+ (s[r]-\'a\'+1))%mod;\n            if((noOfLetter<=maxLetters) && (r-l+1)==minSize){\n                ans=max(ans,++freq[hash_curr]);\n            }\n        }\n        return ans;\n    }\n};\n```
['Two Pointers', 'Rolling Hash', 'C++']