package leetcode;

/**
 * https://leetcode.com/problems/get-equal-substrings-within-budget/
 */
public class Problem1208 {
    public int equalSubstring(String s, String t, int maxCost) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1208 prob = new Problem1208();
        System.out.println(prob.equalSubstring("abcd", "bcdf", 3)); // 3
        System.out.println(prob.equalSubstring("abcd", "cdef", 3)); // 1
        System.out.println(prob.equalSubstring("abcd", "acde", 0)); // 1
        System.out.println(prob.equalSubstring("abcd", "bxdf", 2)); // 1
    }
}

@@ -193,32 +193,521 @@
     
-// TODO%0A        return 0
+int size = s.length();%0A        int prev = 0;%0A        int answer = 0;%0A        int cost = maxCost;%0A        for (int cur = 0; cur %3C size; cur++) %7B%0A            int diff = Math.abs(s.charAt(cur) - t.charAt(cur));%0A            cost -= diff;%0A            if (cost %3C 0) %7B%0A                cost = maxCost;%0A                answer = Math.max(answer, cur - prev);%0A                prev = cur;%0A            %7D%0A        %7D%0A        if (cost %3E= 0) %7B%0A            answer = Math.max(answer, size - 1 - prev);%0A        %7D%0A        return answer
 ;%0A  
@@ -798,24 +798,26 @@
 blem1208();%0A
+//
         Syst
@@ -877,16 +877,95 @@
 ); // 3%0A
+//        System.out.println(prob.equalSubstring(%22abaace%22, %22bcxbdf%22, 3)); // 3%0A
         
@@ -1021,32 +1021,34 @@
 def%22, 3)); // 1%0A
+//
         System.o
@@ -1100,24 +1100,26 @@
 , 0)); // 1%0A
+//
         Syst

Update problem 1208