Simple Java Solution
\npublic int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        int maxFreq = 0;\n        for (int size = minSize; size <= maxSize; size++) 
```\npublic int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        int maxFreq = 0;\n        for (int size = minSize; size <= maxSize; size++) {\n            maxFreq = Math.max(maxFreq, getMaxFreqWithThisSize(s, maxLetters, size));\n        }\n        return maxFreq;\n    }\n\n    private int getMaxFreqWithThisSize(String str, int maxLetters, int size) {\n        Map<String, Integer> map = new HashMap<>();\n        for (int i = 0; i <= str.length() - size; i++) {\n            String substring = str.substring(i, i + size);\n            Set<Character> set = new HashSet<>();\n            for (int j = 0; j < substring.length(); j++) {\n                set.add(substring.charAt(j));\n                if (set.size() > maxLetters) {\n                    break;\n                }\n            }\n            if (set.size() <= maxLetters) {\n                map.put(substring, map.getOrDefault(substring, 0) + 1);\n            }\n        }\n        int max = 0;\n        for (String key : map.keySet()) {\n            max = Math.max(max, map.get(key));\n        }\n        return max;\n    }\n```
[]