Easy solution in C++ using  Set and Map
\n\nclass Solution {//TC:O(N) SC:O(N)\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        int n = s.length();\n        int 
\n```\nclass Solution {//TC:O(N) SC:O(N)\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        int n = s.length();\n        int ans = 0;\n        map<string,int>map;\n        for(int i = 0;i<= n - minSize;i++) {\n            map[s.substr(i,minSize)]++;\n        }\n\n        for(auto [x,y]:map) {\n            set<char>substring(x.begin(),x.end());//for unique characters in the substring\n            if(substring.size() <= maxLetters) {\n                ans = max(ans,y);\n            }\n        }\n        return ans;\n    }\n};\n```
['Ordered Map', 'Ordered Set', 'C++']