• Input: "ab", ".*c"

Output: true

Expected: false

Why? I think ".*" means "........"(unlimited number) which can include any string.

And in the example ——isMatch("ab", ".*") → true

I was very confused.

• It's ".*c", so the first string should end with 'c'

• while, you need look at this example given in the subject.
isMatch("aab", "c*a*b") → true.
It means in the algorithm " isMatch(string s, string p)", p can include char which doesn't appear in s. Based on your comment, maybe the truth is if matching successed, p should end ???

• * Matches zero or more of the preceding element.
So c* can matches empty string.

• for c* in the example isMatch("aab", "c*a*b") → true, * matches zero or more of the preceding element, but c still exist. So it equals to isMatch("aab", "ca*b") → true? Thanks!

• No. '*' Matches zero or more of the preceding element. Note "proceeding" which needs be adjacent.

• thanks, I finally understand what I have understood is wrong... Have a nice day~

• I had the same confusion, and figured it out by enforcing the same end. I think this is really not clear in the question itself. p can have redundant sting on the left, but not on the right of s.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.