IsMatch("ab", ".*") = true but isMatch("ab", ".*c")=false


  • 9
    J

    In the problem example case:
    isMatch("ab", ".*") → true

    while the Input ("ab", ".*c") Expected output is false??


  • 0
    S

    Totally agreed!

    Here is another one. How come isMatch("c", "cab") and isMatch("a", "cab") returns false? It's expected true, right?
    However, isMatch("b", "cab") does return true!


  • 9
    H

    I think the key is how to understand "match". I'm confused at the beginning,too. After seeing the discussion ,I find out that "match" seems to mean "equal" in this problem. So ".*" =".."="ab". But ".*c" must contain 'c', but "ab" does not contain 'c'.


  • 0
    J

    @huster But this also says true:

    "aab", "c*a*b"
    

    S doesn't contain "c"


  • 0
    J

    @jimjea 'cab' = 'a*b'= 'aab'


  • 0
    L

    @jimjea c* can match any amount of c, here it can match zero c,
    then a* matches two a(s), this is why cab can match aab


  • 0
    H

    @Leiduan
    so in the case [isMatch("ab", ".") → true] which is defined as a example of this problem, the dot match the 'a', then the star means 'Matches zero or more of the preceding element.', i don't know which character in '.' can match 'b'.
    ...I can not understand, I think this problem has a bug...


  • 0
    P

    @JayFang1993 I'm confused by this problem too. And I think that the second string contains the first string is true but the result is false...


Log in to reply
 

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