@@ -0,0 +1,970 @@
+// Solution runs in O(s1 * s2) time and uses O(s1 * s2) space.%0A// Beats 90.59%25 of all submissions%0A// Here we use recursion with memoization.%0Aclass Solution %7B%0A  public boolean isInterleave(String s1, String s2, String s3) %7B%0A    if (s1.length() + s2.length() != s3.length()) return false;%0A    return helper(s1, 0, s2, 0, s3, 0, new int%5Bs1.length() + 1%5D%5Bs2.length() + 1%5D);%0A  %7D%0A%0A  private boolean helper(String s1, int p1, String s2, int p2, String s3, int p3, int%5B%5D%5B%5D memo) %7B%0A    if (p1 == s1.length() && p2 == s2.length() && p3 == s3.length()) return true;%0A    if (p1 %3E= s1.length() && p2 %3E= s2.length() %7C%7C p3 %3E= s3.length()) return false;%0A    if (memo%5Bp1%5D%5Bp2%5D != 0) return memo%5Bp1%5D%5Bp2%5D == 1;%0A    boolean res =%0A      p1 %3C s1.length() && s1.charAt(p1) == s3.charAt(p3) && helper(s1, p1+1, s2, p2, s3, p3+1, memo) %7C%7C%0A      p2 %3C s2.length() && s2.charAt(p2) == s3.charAt(p3) && helper(s1, p1, s2, p2+1, s3, p3+1, memo);%0A    memo%5Bp1%5D%5Bp2%5D = res ? 1 : -1;%0A    return res;%0A  %7D%0A%7D%0A

add solution