← 返回 meta 的题目列表Pattern Matching with Digits Representing Greedy Character Counts
类型:online_judge
meta
Match 'internationalization' pattern in the input string
You are given a pattern string pattern and an input string input_str, where pattern can contain lowercase letters and digits. Digits represent a greedy match of the corresponding number of any characters. Determine if input_str matches the pattern.
Example
Input: pattern = "i18n", input_str = "internationalization"
Output: true
Explanation: The digit "18" in the pattern matches the string "internationaliz"
Input: pattern = "p2r", input_str = "paper"
Output: true
Explanation: The pattern "2" greedily matches "ape"
Input: pattern = "a2c", input_str = "ark"
Output: false
Explanation: The digit "2" expects to match two characters, but there is only one character matching in "ark".
Constraints
Both pattern and input_str consist of lowercase letters and digits
The length of pattern is up to 100
The length of input_str is up to 1000
Example
Input
pattern = "i18n", input_str = "internationalization"