I think my solution is pretty straightforward - there are two base cases: the first character in the pattern is '*' and the first character of the pattern is not '*'. I have to be careful for some edge cases, but that is fine (like the length of the pattern is equal to 1, but the length of the string is less than 1). Here is my solution:

```
public boolean isMatch(String s, String p) {
//if the length of the pattern is 0 => check the length of the string for 0
if(p.length()==0)
return s.length()==0;
//if the first character in the pattern is not '*' or if the pattern has lenght 1
if(p.length()==1 || p.charAt(0) != '*'){
if(s.length()<1 || (p.charAt(0) != '?' && p.charAt(0) != s.charAt(0)))
return false;
return isMatch(s.substring(1), p.substring(1));
}
//if the first character of the pattern is '*' try to iterate over the shole string till mach is found
else{
int len = s.length();
int i = -1;
while(i < len){
if(isMatch(s.substring(i+1), p.substring(1)))
return true;
i++;
}
return false;
}
}
```

Can someone explain me why I have time limit exceeded on the following test case:

Last executed input:

"abbabbbaabaaabbbbbabbabbabbbabbaaabbbababbabaaabbab",

"aabbaaa*****aa"