美文网首页
192. Wildcard Matching

192. Wildcard Matching

作者: 鸭蛋蛋_8441 | 来源:发表于2019-07-11 14:14 被阅读0次

    Description

    Implement wildcard pattern matching with support for '?' and '*'.

    '?' Matches any single character.

    '*' Matches any sequence of characters (including the empty sequence).

    The matching should cover the entire input string (not partial).

    Example

    Example 1

    Input:

    "aa"

    "a"

    Output: false

    Example 2

    Input:

    "aa"

    "aa"

    Output: true

    Example 3

    Input:

    "aaa"

    "aa"

    Output: false

    Example 4

    Input:

    "aa"

    "*"

    Output: true

    Explanation: '*' can replace any string

    Example 5

    Input:

    "aa"

    "a*"

    Output: true

    Example 6

    Input:

    "ab"

    "?*"

    Output: true

    Explanation: '?' -> 'a' '*' -> 'b'

    Example 7

    Input:

    "aab"

    "c*a*b"

    Output: false

    思路:

    基于记忆化搜索的dfs, 递归的结束条件有点难想,各种情况。

    代码:

    相关文章

      网友评论

          本文标题:192. Wildcard Matching

          本文链接:https://www.haomeiwen.com/subject/ihzrkctx.html