Java Solution || Sliding-Window || Faster than 85%
```java \nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        int[] a = new int[26];\n        Map map = new 
```java \nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        int[] a = new int[26];\n        Map<String,Integer> map = new HashMap<>();\n        int c=0; //unique count\n        int max=0;\n        for(int j=0;j<minSize;j++)\n            if(a[s.charAt(j)-\'a\']++==0)\n                c++;\n        \n        if(c<=maxLetters){\n            max=1;\n            map.put(s.substring(0,minSize),1);\n        }\n        \n        for(int j=minSize;j<s.length();j++)\n        {\n            if(a[s.charAt(j)-\'a\']++==0)\n                c++;\n                \n            if(a[s.charAt(j-minSize)-\'a\']--==1)\n                c--;\n            \n            if(c<=maxLetters){\n                String temp = s.substring(j-minSize+1,j+1);\n                int freq = map.getOrDefault(temp, 0) + 1;\n                if(max<freq)\n                    max=freq;\n                map.put(temp,freq);\n            }\n        }\n        return max;\n    }\n}
['Sliding Window']