How to optimize my code for wildcard pattern

So my code it passing some 6 cases while giving TLE in 1 and wrong answer in another. Can someone tell me what am i doing wrong and how to optimise my code https://ide.codingblocks.com/s/262969

Your code fails on this test
aa aa*
think how to tackle such case!
Also initialize dp with -1 as 0 can also be an answer.

ohhh. Thanks. Didnt think about this

Still not able to pass 1 last test case. Its showing run time error

Allocate DP array dynamically!
think of case where length of strings are 100 and 100000!

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.