Java easy to understand solution O(n)
Thanks to rorua, I realized that maxSize doesn\'t really matter for this problem.\n\nThe reason is that for example "aababcaab" maxLetter = 2, minSize = 3, maxS
Thanks to [rorua](https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/discuss/734807/Hint%3A-maxSize-doesn\'t-matter!), I realized that maxSize doesn\'t really matter for this problem.\n\nThe reason is that for example "aababcaab" maxLetter = 2, minSize = 3, maxSize = 4\nOnce we found "aa" occur twice we know anything longer cannot occur more than that. Therefore the substring length construct with minSize is always >= substring length construct with maxSize. \n\nThe other condition that makes the algotihm O(n) is one of the constraints states: **1 <= minSize <= maxSize <= min(26, s.length)**\n\n```\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        if(s == null || s.length() == 0 || maxLetters == 0) return 0;\n        HashMap<String, Integer> hm = new HashMap<>();\n        int max = 0;\n        for(int i = 0; i < s.length() - minSize + 1; i++) {\n            String cur = s.substring(i, i + minSize);\n            if(isValid(cur, maxLetters)) {\n                hm.put(cur, hm.getOrDefault(cur, 0) + 1);\n                max = Math.max(max, hm.get(cur));\n            }\n        }\n        return max;\n    }\n\t\n    boolean isValid(String cur, int maxLetters) {\n\t\t// length of cur  = minSize and makes this method run O(1)\n        HashSet<Character> hs = new HashSet<>();\n        for(char c: cur.toCharArray()) hs.add(c);\n        return hs.size() <= maxLetters;\n    }\n}\n```
[]