A string can be abbreviated by replacing any number of non-adjacent, non-empty substrings with their lengths. The lengths should not have leading zeros. For example, a string such as "substitution" could be abbreviated as (but not limited to): "s10n", "sub4u4", "12", "su3i1u2on". Given a string word and an abbreviation abbr, return whether the string matches the given abbreviation.
Example 1
Input: word = internationalization, abbr = i12iz4n
Output: true
Explanation: Match 'i', skip 12 letters ("nternational"), match "iz", skip 4 letters ("atio"), and match the final 'n'. That uses all 20 letters exactly.
Example 2
Input: word = apple, abbr = a2e
Output: false
Explanation: Match 'a', skip 2 letters ("pp"), and the next letter should be 'e', but it is 'l'. The abbreviation does not match.
Example 3
Input: word = substitution, abbr = s10n
Output: true
Explanation: Match 's', skip 10 letters ("ubstitutio"), and match the final 'n'. That covers all 12 letters.
Walk both strings together. A digit run in the abbreviation is a skip count over the word; a letter must match the current word character.
Run checks all cases above. Submit evaluates all test cases.