package leetcode;

/**
 * https://leetcode.com/problems/count-substrings-that-differ-by-one-character/
 */
public class Problem1638 {
    public int countSubstrings(String s, String t) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1638 prob = new Problem1638();
        System.out.println(prob.countSubstrings("aba", "baba")); // 6
        System.out.println(prob.countSubstrings("ab", "bb")); // 3
        System.out.println(prob.countSubstrings("a", "a")); // 0
        System.out.println(prob.countSubstrings("abe", "bbc")); // 10
        System.out.println(prob.countSubstrings("computer", "computation")); // 90
    }
}

@@ -192,32 +192,888 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        int minLength = Math.max(s.length(), t.length());%0A        for (int length = 1; length %3C= minLength; length++) %7B%0A            for (int i = 0; i %3C= s.length() - length; i++) %7B%0A                String sub1 = s.substring(i, i + length);%0A                for (int j = 0; j %3C= t.length() - length; j++) %7B%0A                    String sub2 = t.substring(j, j + length);%0A                    int count = 0;%0A                    for (int k = 0; k %3C length; k++) %7B%0A                        if (sub1.charAt(k) != sub2.charAt(k)) %7B%0A                            count++;%0A                        %7D%0A                        if (count %3E 1) %7B%0A                            break;%0A                        %7D%0A                    %7D%0A                    if (count == 1) %7B%0A                        answer++;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return answer
 ;%0A  

Update problem 1638