JAVA | SLIDING WINDOW + LOOP + LOGIC == ✔ With Explanation
\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n\t  //creating map to keep track of count of eligible substrin
```\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n\t  //creating map to keep track of count of eligible substrings\n        HashMap<String,Integer> map = new HashMap();\n        \n        \n        int i = 0;\n        \n        int n = s.length();\n        \n        while(i <= n-minSize){\n\t\t  //creating set to keep track of maxLetters.\n            Set<Character> set = new HashSet();\n\t\t\t// creating temporary string to hold our substring\n            StringBuilder sb = new StringBuilder();\n            int j = i;\n\t\t\t//using sliding window technique to iterate and keep track of substring which are under our conditions\n            while(j < n && set.size() <= maxLetters){\n                set.add(s.charAt(j));\n                if(set.size() <= maxLetters){\n                    sb.append(s.charAt(j));\n                    if(sb.length() >= minSize && sb.length() <= maxSize){\n\t\t\t\t\t//adding our substring to map\n                        map.put(sb.toString(),map.getOrDefault(sb.toString(),0)+1);\n                    }\n                }\n                j++;\n            }\n            i++;\n        }\n        \n        int max = 0;\n        //interating from all substring and track our max occuring one\n        for(String key : map.keySet()){\n            max = Math.max(map.get(key),max);\n        }\n        \n        return max;\n        \n    }\n}\n```
['Sliding Window', 'Java']