Easy Java Solution 70% faster with explanation
\n//concept 1- if a string occurs x times then its substring also occur x times\n//concept 2- so if a max length substring occur x times then its sure that smal
```\n//concept 1- if a string occurs x times then its substring also occur x times\n//concept 2- so if a max length substring occur x times then its sure that smallest substring also occur x times. So we can ignore about maxlength substring\n//concept 3- we need to take account of the overlapping substring.\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n\t\tHashMap<String, Integer> map = new HashMap<String, Integer>();\n        for(int i=0;i<s.length()-minSize+1;i++)\n        {\n        \tString sub = s.substring(i, i + minSize);\n        \tif(countUnique(sub,maxLetters))\n        \t{\n        \t\tmap.put(sub, map.getOrDefault(sub, 0)+1);\n        \t}\n        }\n\t\tArrayList<Integer> cou = new ArrayList<Integer>(map.values());\n\t\tCollections.sort(cou);\n\t\tif (cou.size() == 0)\n\t\t\treturn 0;\n\t\treturn cou.get(cou.size() - 1);\n    }\n    public boolean countUnique(String s,int maxLetters)\n\t{\n\t\tHashMap<Character, Integer> map = new HashMap<Character, Integer>();\n\t\tfor (char c : s.toCharArray()) {\n\t\t\tmap.put(c, map.getOrDefault(c, 0) + 1);\n\t\t}\n\t\treturn map.size() <= maxLetters;\n\t}\n}\n```
[]