A string can beabbreviatedby 服务器托管网replacing any number ofnon-adjacent,non-emptysubstrings with their lengths. The lengthsshould nothave leading zeros.
For example, a string such as"substitution"
could be abbreviated as (but not limited to):
-
"s10n"
("s ubstitutio n"
) -
"sub4u4"
("sub stit u tion"
) -
"12"
("substitution"
) -
"su3i1u2on"
("su bst i t u ti on"
) -
"substitution"
(no substrings replaced)
The following arenot validabbreviations:
-
"s55n"
("s ubsti tutio n"
, the replaced substrings are adjacent) -
"s010n"
(has leading zeros) -
"s0ubstitution"
(replaces an empty substring)
Given a stringword
and an abbreviationabbr
, returnwhether the stringmatchesthe given abbreviation.
Asubstringis a contiguousnon-emptysequence of characters within a string.
Example 1:
Input: word = "internationalization", abbr = "i12iz4n" Output: true Explanation: The word "internationalization" can be abbreviated as "i12iz4n" ("i nternational iz atio n").
Example 2:
Input: word = "apple", abbr = "a2e" Output: false Explanation: The word "apple" cannot be abbreviated as "a2e".
Constraints:
1
-
word
consists of only lowercase English letters. 1
-
abbr
consists of lowercase English letters and digits. - All the integers in
abbr
will fit in a 32-bit integer.
class Solution {
public boolean validWordAbbreviation(String word, String abbr)服务器托管网 {
int i = 0;
int j = 0;
while(i
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
相关推荐: Azure OpenAI 初体验 – 20230619
参考文档: Quickstart – Get started using ChatGPT and GPT-4 with Azure OpenAI Service – Azure OpenAI Service | Microsoft Learn 先决条件 Azu…