Test cases of wild card pattern mathing not passing completely

In the problem ,Wildcard Pattern Matching,i am able to passs 70 % test cases but dont know why the remaining 30% are not getting passed.
Here is the code i have written


this is a classic 2D DP problem, I have added that solution with comments, you can go through it and it passes all the TC as well

But if we do it via 2d DP then we have to allocate m*n space atleast whose max limit is 100000000 but the maximum size we can allocate in array is 1 million then how is it be able to pass those worst case test cases?

oh ok ok, there are two fixes for that
global initialisation will help
secondly, did u notice how at any point, all I needed was previous two values?
Here is a hint, it was asked in an interview, one from the faang, I think you should try that