public boolean isInterleave(char[] s1, int i1, char[] s2, int i2, char[] s3,
int i3) {
if (i3 == s3.length) {
if (i1 == s1.length && i2 == s2.length) return true;
return false;
}
if (i1 < s1.length && s1[i1] == s3[i3] && this.isInterleave(s1, i1 + 1, s2
, i2, s3, i3 + 1))
return true;
if (i2 < s2.length && s2[i2] == s3[i3] && this.isInterleave(s2, i2 + 1, s1
, i1, s3, i3 + 1))
return true;
return false;
}
public boolean isInterleave(String s1, String s2, String s3) {
if (s1 == null || s2 == null || s3 == null)
return false;
return this.isInterleave(s1.toCharArray(), 0, s2.toCharArray(), 0,
s3.toCharArray(), 0) ||
this.isInterleave(s2.toCharArray(), 0, s1.toCharArray(), 0,
s3.toCharArray(), 0);
}