One test case failing please check
Please check your logic again because what you are doing , if any string ends before other string then you are returning true but let suppose you have
Example -
aa
a
For this case the output should be NOT MATCHED but your code gives MATCHED.
First character matches and then second string ends and you return true but thats not the case.
Think a little bit more and also see constraints.
I am unable to do it furthur could you please tell?
You can see the states of dp. And try to implement it. If you can’t just let me know.
/*
* dp[i][j]: Whether the substring of s ending at the index i can
be matched by the subpattern of p ending at the index j.
* | if s[i] == p[j] || p[j] == '?', dp[i - 1][j - 1]
dp[i][j] = | if p[j] == '*' , dp[i - 1][j] || dp[i][j- 1]
| otherwise , false
*/
see i got how the code is working but i am still struggling with making the dp arrays can suggest how to improve it
Just try to do it in copy and get the logic and then fill the table whatever logic is working while doing in notebook. With doing lots of question you will directly be able to do it.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.