C++ || EASY TO UNDERSTAND || 2 methods
\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n      unordered_map<char,int> mp;\n      unordered_map<strin
```\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n      unordered_map<char,int> mp;\n      unordered_map<string,int> mp2;\n      int i=0,n=s.size();\n      int j=0,res=0;\n        while(j<n)\n        {\n            mp[s[j]]++;\n            if(j-i+1>minSize)\n            {\n                if(--mp[s[i]]==0)\n                {\n                    mp.erase(s[i]);\n                }\n                i++;\n            }\n            if(j-i+1==minSize&&mp.size()<=maxLetters)\n            {\n                string str=s.substr(i,j-i+1);\n                mp2[str]++;\n                res=max(res,mp2[str]);\n            }\n            j++;\n        }\n        return res;\n    }\n};\n```
[]