Valid Word Abbreviation
Given anon-emptystrings
and an abbreviationabbr
, return whether the string matches with the given abbreviation.
A string such as"word"
contains only the following valid abbreviations:
Notice that only the above abbreviations are valid abbreviations of the string"word"
. Any other string is not a valid abbreviation of"word"
.
Note:
Assumes
contains only lowercase letters andabbr
contains only lowercase letters and digits.
Example 1:
Example 2:
Analysis
Easy题,但是有许多实现细节容易出问题。
用
Character.isDigit(t[j])
来检测是否为数字数字字符到数字的转换
while嵌套while循环要注意内层循环中的指针不要越界
Solution
Reference
Last updated