MicrosoftOA #71
Word Pattern II (Round 1, LC 291 :)
估计中等可在线判题
考点(AI 标注)拆分构造
Map each distinct character of pattern to a non-empty string, such that the same character always maps to the same string and different characters cannot map to the same string. Concatenate the mapped strings following the pattern, and determine whether the result can be exactly s.
This site uses a standard input/output protocol.
输入格式
Two lines, pattern and s, both containing only lowercase letters, each of length 1..20.
输出格式
Output a single integer, the answer.
样例 1
输入:
abab
redblueredblue
输出:
1
样例 2
输入:
aaaa
asdasdasdasd
输出:
1
样例 3
输入:
aabb
xyzabcxyzabc
输出:
0
样例说明
Example 1: a→red and b→blue form the target, so output 1. Example 2: a→asd repeated 4 times matches exactly, so output 1. Example 3: the string cannot be split into two identical a strings followed by two identical b strings, so output 0.