package leetcode;

/**
 * https://leetcode.com/problems/interleaving-string/
 */
public class Problem97 {
    public boolean isInterleave(String s1, String s2, String s3) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem97 prob = new Problem97();
        System.out.println(prob.isInterleave("aabcc", "dbbca", "aadbbcbcac")); // true
        System.out.println(prob.isInterleave("aabcc", "dbbca", "aadbbbaccc")); // false
    }
}

@@ -178,24 +178,66 @@
     
-// TODO%0A
+if (s1.length() + s2.length() != s3.length()) %7B%0A  
         
 retu
@@ -232,16 +232,18 @@
         
+  
 return f
@@ -256,272 +256,1113 @@
     
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem97 prob = new Problem97();%0A        System.out.println(prob.isInterleave(%22aabcc%22, %22dbbca%22, %22aadbbcbcac%22)); // true%0A        System.out.println(prob.isInterleave(%22aabcc%22, %22dbbca%22, %22aadbbbaccc%22)); // false
+    %7D%0A        int%5B%5D%5B%5D%5B%5D memo = new int%5Bs1.length() + 1%5D%5Bs2.length() + 1%5D%5Bs3.length() + 1%5D;%0A        // -1 -%3E false%0A        // 0  -%3E uninitialized%0A        // 1  -%3E true%0A        return isInterleave(s1, s2, s3, 0, 0, 0, memo);%0A    %7D%0A%0A    private static boolean isInterleave(String s1, String s2, String s3, int i, int j, int k,%0A                                        int%5B%5D%5B%5D%5B%5D memo) %7B%0A        if (i == s1.length() && j == s2.length() && k == s3.length()) %7B%0A            return true;%0A        %7D%0A        if (memo%5Bi%5D%5Bj%5D%5Bk%5D != 0) %7B%0A            return memo%5Bi%5D%5Bj%5D%5Bk%5D == -1 ? false : true;%0A        %7D%0A        boolean found = false;%0A        if (i %3C s1.length()) %7B%0A            if (s1.charAt(i) == s3.charAt(k)) %7B%0A                found %7C= isInterleave(s1, s2, s3, i + 1, j, k + 1, memo);%0A            %7D%0A            if (found) %7B%0A                return found;%0A            %7D%0A        %7D%0A        if (j %3C s2.length()) %7B%0A            if (s2.charAt(j) == s3.charAt(k)) %7B%0A                found %7C= isInterleave(s1, s2, s3, i, j + 1, k + 1, memo);%0A            %7D%0A        %7D%0A        memo%5Bi%5D%5Bj%5D%5Bk%5D = (found) ? 1 : -1;%0A        return found;
 %0A   

Solve problem 97