public class Solution {
public boolean isInterleave(String s1, String s2, String s3) {
if(s1.length()+s2.length()!=s3.length())return false;
boolean[][]c=new boolean[s1.length()+1][s2.length()+1];
c[0][0]=true;
for(int i=0;i<s1.length();i++){
if(s1.charAt(i)==s3.charAt(i))
c[i+1][0]=true;
else break;
}
for(int i=0;i<s2.length();i++){
if(s2.charAt(i)==s3.charAt(i))
c[0][i+1]=true;
else break;
}
for(int i=1;i<s1.length()+1;i++){
for(int j=1;j<s2.length()+1;j++){
char c3=s3.charAt(i+j-1);
if(s1.charAt(i-1)==c3){
c[i][j]=c[i-1][j];
}
if(s2.charAt(j-1)==c3){
c[i][j]=c[i][j-1]||c[i][j];
}
}
}
return c[s1.length()][s2.length()];
}
}