Javascript O(n) solution
Checking for minSize alone should give the desired result, since that is the maximum possible result one could get.\n\n/**\n * @param {string} s\n * @param {num
Checking for minSize alone should give the desired result, since that is the maximum possible result one could get.\n```\n/**\n * @param {string} s\n * @param {number} maxLetters\n * @param {number} minSize\n * @param {number} maxSize\n * @return {number}\n */\nvar maxFreq = function(s, maxLetters, minSize, maxSize) {\n    var cache = new Map();\n    var result = 0;\n    var curr;\n    var set;\n    for (let j = 0; j <= s.length - minSize; j++) {\n        curr = s.substr(j, minSize);\n        set = new Set(curr.split(\'\'))\n        if (set.size <= maxLetters) {\n            if (cache.has(curr)) {\n                cache.set(curr, cache.get(curr) + 1);\n            } else {\n                cache.set(curr, 1);\n            }\n\n            if (cache.get(curr) > result) {\n                result = cache.get(curr);\n            }\n        }\n    }\n    \n    return result;\n};\n```
[]