hi, guys,

The following code is working:

```
public class Solution {
public boolean isInterleave(String s1, String s2, String s) {
return isInterleave(s1, s1.length()-1, s2, s2.length()-1, s, s.length()-1);
}
public boolean isInterleave(String s1, int i1, String s2, int i2, String s, int i){
if(i<0){
if(i1<0 && i2<0) return true;
else return false;
}
if(i1 >= 0 && s1.charAt(i1)==s.charAt(i) && isInterleave(s1,i1-1,s2,i2,s,i-1))
return true;
if(i2 >= 0 && s2.charAt(i2)==s.charAt(i) && isInterleave(s1,i1,s2,i2-1,s,i-1))
return true;
return false;
}
}
```

But when I tried recursion from the head, time limit exceeded:

```
public class Solution {
public boolean isInterleave(String s1, String s2, String s) {
return isInterleave(s1, 0, s2, 0, s, 0);
}
public boolean isInterleave(String s1, int i1, String s2, int i2, String s, int i){
if(i>=s.length()){
if(i1>=s1.length() && i2>=s2.length()) return true;
else return false;
}
if(i1 < s1.length() && s1.charAt(i1)==s.charAt(i) && isInterleave(s1,i1+1,s2,i2,s,i+1))
return true;
if(i2 < s2.length() && s2.charAt(i2)==s.charAt(i) && isInterleave(s1,i1,s2,i2+1,s,i+1))
return true;
return false;
}
}
```

I just feel they are totally equivalent.

Do someone have an idea? Thanks!