package leetcode;

/**
 * https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/
 */
public class Problem1297 {
    public int maxFreq(String s, int maxLetters, int minSize, int maxSize) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1297 prob = new Problem1297();
        System.out.println(prob.maxFreq("aababcaab", 2, 3, 4)); // 2
        System.out.println(prob.maxFreq("aababcaab", 2, 2, 4)); // 3
        System.out.println(prob.maxFreq("aababcaabaa", 2, 2, 4)); // 3
        System.out.println(prob.maxFreq("aaaa", 1, 3, 3)); // 2
        System.out.println(prob.maxFreq("aabcabcab", 2, 2, 3)); // 3
        System.out.println(prob.maxFreq("abcde", 2, 3, 3)); // 0
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -248,24 +248,395 @@
  maxSize) %7B%0A
+        int answer = 0;%0A        for (int i = minSize; i %3C maxSize; i++) %7B%0A            String sub = s.substring(0, i);%0A            Map%3CCharacter, Integer%3E charCount = new HashMap%3C%3E();%0A            for (char c : sub.toCharArray()) %7B%0A                int count = charCount.getOrDefault(c, 0);%0A                if (count == 0 && charCount.size() + 1 %3E maxLetters) %7B%0A            
         // T
@@ -651,16 +651,886 @@
     
+  
-return 0
+      %7D%0A                if (!charCount.containsKey(c)) %7B%0A                    charCount.put(c, 1);%0A                %7D else %7B%0A                    charCount.put(c, charCount.get(c) + 1);%0A                %7D%0A            %7D%0A            Map%3CString, Integer%3E strCount = new HashMap%3C%3E();%0A            strCount.put(sub, 1);%0A            for (int j = minSize + 1; j %3C s.length(); j++) %7B%0A                char c = s.charAt(j);%0A                int count = charCount.getOrDefault(c, 0);%0A                if (count == 0 && charCount.size() + 1 %3E maxLetters) %7B%0A                    // TODO%0A                %7D%0A                if (!charCount.containsKey(c)) %7B%0A                    charCount.put(c, 1);%0A                %7D else %7B%0A                    charCount.put(c, charCount.get(c) + 1);%0A                %7D%0A                sub = sub.substring(1) + s.charAt(j);%0A            %7D%0A        %7D%0A        return answer
 ;%0A  
@@ -1686,32 +1686,105 @@
 2, 3, 4)); // 2%0A
+//        System.out.println(prob.maxFreq(%22aababcaab%22, 1, 1, 4)); // 5%0A//
         System.o
@@ -1828,32 +1828,34 @@
 2, 2, 4)); // 3%0A
+//
         System.o
@@ -1901,32 +1901,34 @@
 2, 2, 4)); // 3%0A
+//
         System.o
@@ -1975,16 +1975,18 @@
 ); // 2%0A
+//
         
@@ -2046,16 +2046,18 @@
 ); // 3%0A
+//
         

Update problem 1297