Java -  Easy to understand - Sliding Window
```\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        int i=0;\n        int start=0;\n        int count=0
```\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        int i=0;\n        int start=0;\n        int count=0;\n        HashMap<String, Integer> res=new HashMap<>();\n        HashMap<Character, Integer> hm = new HashMap<>();\n\t\t//MaxSize doesn\'t matter\n        for(int k=minSize;k<=minSize;k++) {\n        \ti=0;\n        \tstart=0;\n        while(i<s.length()) {\n        \thm.put(s.charAt(i), hm.getOrDefault(s.charAt(i), 0)+1);\n        \tif(i-start+1==k) {\n        \t\tif(hm.size()<=maxLetters) {\n        \t\tres.put(s.substring(start,i+1), res.getOrDefault(s.substring(start,i+1),0)+1);\n        \t\t}\n        \t\tif(hm.get(s.charAt(start))-1==0)\n        \t\t\thm.remove(s.charAt(start));\n        \t\telse hm.put(s.charAt(start),hm.get(s.charAt(start))-1);\n        \t\tstart++;\n        \t\n        }\n        \ti++;\n        }\n        }\n        return res.size()==0?0:Collections.max(res.values());\n    }\n}\n
[]