← 返回 meta 的题目列表String Abbreviation Matching
类型:online_judge
Given two strings, determine if the first string is an abbreviation of the second string. An abbreviation is defined as replacing any non-empty substring of the string with a number, which represents the length of that substring. For example, 'i18n' is an abbreviation of 'internationalization'. You need to support the following examples:
"i18n" matches "internationalization", but does not match "interpolation".
"f6k" matches "facebook", but does not match "focus".
"F2eb2k" matches "Facebook".
Please implement a function bool is_match(string abbr, string word), that returns whether the abbreviation matches. Assume strings only contain letters and digits.
Example
Input
3
"i18n" "internationalization"
"f6k" "facebook"
"F2eb2k" "Facebook"