Wildcard pattern matching

This question is same as this topic with few modification.
I used the same code as this https://www.geeksforgeeks.org/wildcard-pattern-matching/ but not all the testcases are passing can u please help me