Java sliding-window ,maxSize is useless
The return value is the max number of the substring which follows  the rule given.\n\nIt gives us a maxSize and a minSize  and a maxLetters , but  maxSize is us
The return value is the max number of the substring which follows  the rule given.\n\nIt gives us a maxSize and a minSize  and a maxLetters , but  maxSize is useless !\n\nIf we know a substring A follows the rule occurs the max times with a size more than minSize, \nthen this  A\'s substring, we call it B, whose size is equal to minSize also occurs the same times and it has \nat most the same number of  characters with A , so B also occurs the max time and follow the rule.\n\nSo we just maintain our sliding-window with size minSize , it could make sure that we get the right answer.\n\nComment is welcome !\nHope it helps you.\n```\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        Map<String,Integer> m = new HashMap<>();\n        int ss = 0 ;\n        int ee = 0;\n        Map<Character,Integer> cnt = new HashMap<>();\n\n        while( ee < s.length())\n        {\n            Character cur =s.charAt(ee);\n            cnt.put(cur,cnt.getOrDefault(cur,0)+1);\n             while( ee-ss+1 > minSize  )\n             {\n                 Character c =s.charAt(ss);\n                 if(cnt.get(c)==1)\n                     cnt.remove(c);\n                 else\n                     cnt.put(c,cnt.get(c)-1);\n                 ss++;\n             }\n             if(cnt.size()<=maxLetters &&ee-ss+1>=minSize )\n                m.put(s.substring(ss,ee+1),m.getOrDefault(s.substring(ss,ee+1),0)+1);\n             ee++;\n        }\n        int ans  = 0 ;\n        for( int it : m.values())\n            ans= Math.max(ans,it);\n        return ans;\n    }\n}\n```
['Sliding Window', 'Java']