1、汇总概要
本题是模式匹配问题,解题思路涵盖了递归、以及匹配算法的知识点
2、题目
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).
The function prototype should be:
bool isMatch(const char *s, const char *p)
Some examples:
isMatch("aa","a") ? false
isMatch("aa","aa") ? true
isMatch("aaa","aa") ? false
isMatch("aa", "*") ? true
isMatch("aa", "a*") ? true
isMatch("ab", "?*") ? true
isMatch("aab", "c*a*b") ? false
3、审题
该题是模式匹配问题。
4、解题思路
1、原串(s)和模式串(p)匹配规则考虑时,涉及到三种基本情况,以及其任意组合:
1) 模式串当前是字符时(p[j]是char):相等则继续比较下一个,不相等则返回