C++ Sliding Window No Need To Calculate For All Window Sizes
The maximum frequency will always lie for smallest window size\nans(i size window) >= ans(j size window) where\ni < j\n\nNOTE: We could improve time complexity 
**The maximum frequency will always lie for smallest window size**\nans(i size window) >= ans(j size window) where\ni < j\n\n**NOTE:** We could improve time complexity by using Rabin Karp or KMP.\n\n```\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        vector<int> cnt(26, 0);\n        map<string, int> mp;\n        string str;\n        int unique = 0, mx = 0;\n        for(int i = 0; i < minSize; i++) {\n            if(cnt[s[i] - \'a\']++ == 0) {\n                unique++;\n            }\n            str += s[i]; \n        }\n        if(unique <= maxLetters) {\n            mp[str]++;\n            mx = max(mx, mp[str]);\n        }\n        for(int i = minSize; i < s.size(); i++) {\n            if(cnt[s[i] - \'a\']++ == 0) {\n                unique++;\n            }\n            if(--cnt[s[i - minSize] - \'a\'] == 0) {\n                unique--;\n            }\n            str += s[i];\n            str.erase(str.begin());\n            if(unique <= maxLetters) {\n                mp[str]++;\n                mx = max(mx, mp[str]);\n            }\n        }\n        return mx;\n    }\n};\n```
[]