Wildcard Pattern Matching DP

Question - https://hack.codingblocks.com/contests/c/140/1058
Code - https://ide.codingblocks.com/s/90574
So I’m using top down DP to solve this problem.

At first, I was using a 2D array as memo[][] to store my results, but I faced issues with the constraints as n1*n2 < 100000000. I tried different permutations of memo[n1][n2] but I always got a mininum of 2 testcases showing wrong answer (which were different for a different combination of my memo declaration).
Then, I used a 2D vector to do the same, but this time, I’m getting run-error and TLE in many test cases. What am I doing wrong?

PS: Please feel to ask me to explain my question/code more clearly:p

@pmahajan hey pulkit try to handle this case
bac
ba*a
output is
0
but your code giving runtime error try with this question with 2d approach.If you fail to implement this case do tag I will be help you to solve this problem with 2d approach.

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.