[c++] 48ms, only need minSize, easy-to-understand sliding window O(n)
Intuition:\n1. If string S with size N > minSize has frequency F, then the substring of S must also have frequency F.\n2. Therefore, we only need to consider th
Intuition:\n1. If string `S` with size `N > minSize` has frequency `F`, then the substring of `S` must also have frequency `F`.\n2. Therefore, we only need to consider the `minSize` substring.\n3. Apply sliding window to scan the candidate substrings with length `minSize`.\n```\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        unordered_map<string, int> cnt;\n        \n        int res=INT_MIN, l=0, r=minSize-1, diff=0;\n        char m[26] = {0};\n\n        for (int i=0; i<minSize - 1; i++)\n            if (++m[s[i]-\'a\'] == 1)\n                ++diff;\n\n        while(r<s.size())\n        {\n            if (++m[s[r]-\'a\'] == 1)\n                ++diff;\n\n            if (diff <= maxLetters)\n            {\n                string t = s.substr(l, minSize);\n                ++cnt[t];\n                res = max(res, cnt[t]);\n            }\n\n            if (--m[s[l]-\'a\'] == 0) --diff;\n            ++l;\n            ++r;\n        }\n        \n        return (res == INT_MIN)? 0: res;\n    }\n};\n```
[]