Java || Sliding Window || Easy Understandings
\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        \n        Map<String, Integer> res = new HashMap<>();\
```\nclass Solution {\n    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {\n        \n        Map<String, Integer> res = new HashMap<>();\n        Map<Character, Integer> map = new HashMap<>();\n        int left = 0, right = 0;\n        int max = 0;\n        \n        while(right < s.length()) {\n            char curr = s.charAt(right);\n            map.put(curr, map.getOrDefault(curr, 0) + 1);\n\n            while(map.size() > maxLetters || right - left + 1 > maxSize) {\n                char leftChar = s.charAt(left);\n                map.put(leftChar, map.get(leftChar) - 1);\n                if(map.get(leftChar) == 0) {\n                    map.remove(leftChar);\n                }\n                left++;\n            }\n            while(map.size() <= maxLetters && right - left + 1 >= minSize \n               && right - left + 1 <= maxSize) {\n                String str = s.substring(left, right + 1);\n                res.put(str, res.getOrDefault(str ,0) + 1);\n                max = Math.max(max, res.get(str));\n                \n                char leftChar = s.charAt(left);\n                map.put(leftChar, map.get(leftChar) - 1);\n                if(map.get(leftChar) == 0) {\n                    map.remove(leftChar);\n                }\n                left++;\n            }\n            right++;\n        }\n        return max;\n    }\n}\n```
[]