Please check code for Wildcard Pattern Matching


Also Please explain the logic for code when ‘*’ character is encountered.

hello @sahilkhan2312000131

its logic is something similar to inclusion - exculsion (i.e either we consider * or we discard it) .

case 1 when we discard it (assuming at i we have *)
solve(i,j) = solve(i+1,j)
or
case 2 when we include it i.e we match *(present at i) with character present at j
solve(i,j) = solve(i,j+1) // note j+1 becuase we have matched jth char with * (present at i) , we are not incrementing i becuase it may happen that same * (present at i ) get matched with j+1 or furthur as well .

take or of both the case
solve(i,j) = solve(i+1,j) || solve(i,j+1)

Coding Blocks IDE
Please check the code

check now->

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.