Solution

Analysis

Solution1

Make use of Recursion.

Each time compare first character of two strings, if the character of pattern is ‘.’ or equal to s. Then invoke this function recursively with the rest of p and s.

Check if the scond character of p is ‘*’, if so, we need check if the character of s is equal to the pre character of p. If so, invoke this function recursively with the current p and suffix of s. If not, invoke this function recursively with the suffix of star in p and the current s.