C++ solution || Faster approach || Easy to understand
\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        unordered_map<char, int> letters;\n        unordered
```\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        unordered_map<char, int> letters;\n        unordered_map<string, int> mp;\n        for(int i=0; i<minSize-1; i++)\n            letters[s[i]]++;\n        for(int i=minSize-1; i<s.size(); i++) {\n            letters[s[i]]++;\n            if(letters.size()<=maxLetters) {\n                mp[s.substr(i+1-minSize, minSize)]++;\n            }\n            if(letters[s[i+1-minSize]]>1)\n                letters[s[i+1-minSize]]--;\n            else\n                letters.erase(s[i+1-minSize]);\n        }\n        int ans=0;\n        for(auto i: mp) \n           ans = max(ans, i.second);\n     return ans;\n    }\n};\n/*\nif(find helpful) {\ndo upvote(); // thanks:)\n}\n*/\n```
['C', 'Sliding Window']