AmazonOA #257
Match Strings (Amazon CN)
估计简单可在线判题
考点(AI 标注)字符串
You are given n pairs of text and pattern. Each pattern contains exactly one *, which can be replaced by zero or more lowercase letters; no other character can be modified. Determine whether each pattern can become the entire corresponding text, and output YES or NO in order. The implementation does not use a built-in regex library.
输入格式
The first line contains n, followed by n lines each containing text pat, separated by a space. 1≤n≤10, 1≤length of each text and pattern≤100000; texts are lowercase only, and patterns are lowercase apart from the single *.
输出格式
Output YES or NO on each line, in input order.
样例 1
输入:
2
code co*d
coder co*er
输出:
NO
YES
样例 2
输入:
2
abc ab*bc
abcbc ab*bc
输出:
NO
YES
样例 3
输入:
2
a *
abc abc*
输出:
YES
YES
样例说明
The results are NO/YES, NO/YES and YES/YES. ab*bc needs at least 4 characters; the prefix and the suffix cannot share the same b.