WildCard Pattern Matching giving Tle on 3cases and wrong on one test Case

My solution for Wildcard Pattern Matching problem giving wrong on one test case and tle on 3cases why so?

Link : https://ide.codingblocks.com/s/213637

Hello @sanidhyasamadhiya,

You will get TLE.
It is a standard question of Dynamic Programming.
You can refer to this video.

Let me know if you don’t understand anything.

Hope, this would help.