Java simple Sliding window with hashMap
1, use a map to count the number of different substrings;\n2, loop all substrings from  minlen to maxlen;\n\nclass Solution {\n    public int maxFreq(String s, 
1, use a map to count the number of different substrings;\n2, loop all substrings from  minlen to maxlen;\n```\nclass Solution {\n    public int maxFreq(String s, int mx, int lo, int hi) {\n        char[] arr = s.toCharArray();\n        int res = 0, n = arr.length;\n        Map<String, Integer> map = new HashMap<>();\n        for (int i = lo; i <= hi; i++) {\n            int[] cnt = new int[26];\n            for (int l = 0, r = 0, unq = 0; r < n; r++) {\n                if (cnt[arr[r] - \'a\']++ == 0) unq++;\n                if (r >= i && --cnt[arr[l++] - \'a\'] == 0) unq--;\n                if (r < i - 1 || unq > mx) continue;\n                String key = getKey(arr, Math.max(0, l), r);\n                map.put(key, map.getOrDefault(key, 0) + 1);\n                res = Math.max(res, map.get(key));\n            }\n        }\n        return res;\n    }\n    \n    private String getKey(char[] arr, int l, int r) {\n        StringBuilder sb = new StringBuilder();\n        for (int i = l; i <= r; i++) sb.append(arr[i]);\n        return sb.toString();\n    }\n}\n```
[]