java easy O(n) solution,  beats 99+ (Sliding Window)
The basic idea is to move the start and end pointers to make the current substring in range [start, end) meet requirements.\nOne tricky point is that, we only n
The basic idea is to move the start and end pointers to make the current substring in range **[start, end) **meet requirements.\nOne tricky point is that, **we only need to consider the substring of minSize**. (We can imagine that if a substring with a larger size appears two times, "the substring of this substring" must also appears two times. E.g. "abbacabba". "abba" appears two times,  "abb" must appears two times also.)\nThe time complexity is O(n). Since we only scan the char array one times. And do constant operations each step.\n\n```   \n   public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        char[] ca = s.toCharArray();  \n        int[] charmap = new int[128];\n        Map<String, Integer> strmap = new HashMap<>();\n        int start = 0, end = 0, curletters = 0, max = 0;\n        while (end < s.length()) {\n            char c = ca[end++];    //end++ at here, so range is [start, end)\n            if (charmap[c] == 0) curletters++;   //count the number of letter of current substring\n            charmap[c]++;\n\n            while (end - start > minSize || curletters > maxLetters) {    //move start pointers to delete chars to meet the requirement again\n                char del = ca[start++];\n                if (charmap[del] == 1) curletters--;\n                charmap[del]--;\n            }\n            if (end - start >= minSize) {              //if it\'s valid, store it in the map, and maintain a global max\n                String substr = s.substring(start, end);\n                int occtimes = strmap.getOrDefault(substr, 0) + 1;\n                strmap.put(substr, occtimes);\n                max = Math.max(max, occtimes);\n            }\n        }\n        return max;\n    }\n```\t
[]